Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Hubs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ar-noc
Hubs
Commits
869de4ce
Commit
869de4ce
authored
6 years ago
by
Kevin Lee
Browse files
Options
Downloads
Patches
Plain Diff
cleanup sharedbuffergeometry
parent
35e962a6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/utils/sharedbuffergeometry.js
+4
-17
4 additions, 17 deletions
src/utils/sharedbuffergeometry.js
with
4 additions
and
17 deletions
src/utils/sharedbuffergeometry.js
+
4
−
17
View file @
869de4ce
...
@@ -20,15 +20,14 @@ export default class SharedBufferGeometry {
...
@@ -20,15 +20,14 @@ export default class SharedBufferGeometry {
this
.
idx
.
color
++
;
this
.
idx
.
color
++
;
this
.
idx
.
normal
++
;
this
.
idx
.
normal
++
;
this
.
idx
.
uv
++
;
}
}
}
}
remove
(
prevIdx
,
idx
)
{
remove
(
prevIdx
,
idx
)
{
// Loop through all the attributes: position, color,
uv,
normal,...
// Loop through all the attributes: position, color, normal,...
if
(
this
.
idx
.
position
>
idx
.
position
)
{
if
(
this
.
idx
.
position
>
idx
.
position
)
{
for
(
le
t
key
in
this
.
idx
)
{
for
(
cons
t
key
in
this
.
idx
)
{
const
componentSize
=
key
===
"
uv
"
?
2
:
3
;
const
componentSize
=
3
;
let
pos
=
prevIdx
[
key
]
*
componentSize
;
let
pos
=
prevIdx
[
key
]
*
componentSize
;
const
start
=
(
idx
[
key
]
+
1
)
*
componentSize
;
const
start
=
(
idx
[
key
]
+
1
)
*
componentSize
;
const
end
=
this
.
idx
[
key
]
*
componentSize
;
const
end
=
this
.
idx
[
key
]
*
componentSize
;
...
@@ -39,7 +38,7 @@ export default class SharedBufferGeometry {
...
@@ -39,7 +38,7 @@ export default class SharedBufferGeometry {
this
.
idx
[
key
]
-=
diff
;
this
.
idx
[
key
]
-=
diff
;
}
}
}
else
{
}
else
{
for
(
le
t
key
in
this
.
idx
)
{
for
(
cons
t
key
in
this
.
idx
)
{
const
diff
=
idx
[
key
]
-
prevIdx
[
key
];
const
diff
=
idx
[
key
]
-
prevIdx
[
key
];
this
.
idx
[
key
]
-=
diff
;
this
.
idx
[
key
]
-=
diff
;
}
}
...
@@ -54,12 +53,10 @@ export default class SharedBufferGeometry {
...
@@ -54,12 +53,10 @@ export default class SharedBufferGeometry {
}
}
addBuffer
(
copyLast
)
{
addBuffer
(
copyLast
)
{
console
.
log
(
"
addBuffer
"
,
copyLast
);
const
geometry
=
new
THREE
.
BufferGeometry
();
const
geometry
=
new
THREE
.
BufferGeometry
();
const
vertices
=
new
Float32Array
(
this
.
maxBufferSize
*
3
);
const
vertices
=
new
Float32Array
(
this
.
maxBufferSize
*
3
);
const
normals
=
new
Float32Array
(
this
.
maxBufferSize
*
3
);
const
normals
=
new
Float32Array
(
this
.
maxBufferSize
*
3
);
const
uvs
=
new
Float32Array
(
this
.
maxBufferSize
*
2
);
const
colors
=
new
Float32Array
(
this
.
maxBufferSize
*
3
);
const
colors
=
new
Float32Array
(
this
.
maxBufferSize
*
3
);
const
mesh
=
new
THREE
.
Mesh
(
geometry
,
this
.
material
);
const
mesh
=
new
THREE
.
Mesh
(
geometry
,
this
.
material
);
...
@@ -75,7 +72,6 @@ export default class SharedBufferGeometry {
...
@@ -75,7 +72,6 @@ export default class SharedBufferGeometry {
geometry
.
setDrawRange
(
0
,
0
);
geometry
.
setDrawRange
(
0
,
0
);
geometry
.
addAttribute
(
"
position
"
,
new
THREE
.
BufferAttribute
(
vertices
,
3
).
setDynamic
(
true
));
geometry
.
addAttribute
(
"
position
"
,
new
THREE
.
BufferAttribute
(
vertices
,
3
).
setDynamic
(
true
));
geometry
.
addAttribute
(
"
uv
"
,
new
THREE
.
BufferAttribute
(
uvs
,
2
).
setDynamic
(
true
));
geometry
.
addAttribute
(
"
normal
"
,
new
THREE
.
BufferAttribute
(
normals
,
3
).
setDynamic
(
true
));
geometry
.
addAttribute
(
"
normal
"
,
new
THREE
.
BufferAttribute
(
normals
,
3
).
setDynamic
(
true
));
geometry
.
addAttribute
(
"
color
"
,
new
THREE
.
BufferAttribute
(
colors
,
3
).
setDynamic
(
true
));
geometry
.
addAttribute
(
"
color
"
,
new
THREE
.
BufferAttribute
(
colors
,
3
).
setDynamic
(
true
));
...
@@ -86,7 +82,6 @@ export default class SharedBufferGeometry {
...
@@ -86,7 +82,6 @@ export default class SharedBufferGeometry {
this
.
idx
=
{
this
.
idx
=
{
position
:
0
,
position
:
0
,
uv
:
0
,
normal
:
0
,
normal
:
0
,
color
:
0
color
:
0
};
};
...
@@ -97,7 +92,6 @@ export default class SharedBufferGeometry {
...
@@ -97,7 +92,6 @@ export default class SharedBufferGeometry {
if
(
this
.
previous
&&
copyLast
)
{
if
(
this
.
previous
&&
copyLast
)
{
let
prev
=
(
this
.
maxBufferSize
-
2
)
*
3
;
let
prev
=
(
this
.
maxBufferSize
-
2
)
*
3
;
let
col
=
(
this
.
maxBufferSize
-
2
)
*
3
;
let
col
=
(
this
.
maxBufferSize
-
2
)
*
3
;
const
uv
=
(
this
.
maxBufferSize
-
2
)
*
2
;
let
norm
=
(
this
.
maxBufferSize
-
2
)
*
3
;
let
norm
=
(
this
.
maxBufferSize
-
2
)
*
3
;
const
position
=
this
.
previous
.
attributes
.
position
.
array
;
const
position
=
this
.
previous
.
attributes
.
position
.
array
;
...
@@ -111,8 +105,6 @@ export default class SharedBufferGeometry {
...
@@ -111,8 +105,6 @@ export default class SharedBufferGeometry {
const
color
=
this
.
previous
.
attributes
.
color
.
array
;
const
color
=
this
.
previous
.
attributes
.
color
.
array
;
this
.
addColor
(
color
[
col
++
],
color
[
col
++
],
color
[
col
++
]);
this
.
addColor
(
color
[
col
++
],
color
[
col
++
],
color
[
col
++
]);
this
.
addColor
(
color
[
col
++
],
color
[
col
++
],
color
[
col
++
]);
this
.
addColor
(
color
[
col
++
],
color
[
col
++
],
color
[
col
++
]);
const
uvs
=
this
.
previous
.
attributes
.
uv
.
array
;
}
}
}
}
...
@@ -133,16 +125,11 @@ export default class SharedBufferGeometry {
...
@@ -133,16 +125,11 @@ export default class SharedBufferGeometry {
buffer
.
setXYZ
(
this
.
idx
.
position
++
,
x
,
y
,
z
);
buffer
.
setXYZ
(
this
.
idx
.
position
++
,
x
,
y
,
z
);
}
}
addUV
(
u
,
v
)
{
this
.
current
.
attributes
.
uv
.
setXY
(
this
.
idx
.
uv
++
,
u
,
v
);
}
update
()
{
update
()
{
this
.
current
.
setDrawRange
(
0
,
this
.
idx
.
position
);
this
.
current
.
setDrawRange
(
0
,
this
.
idx
.
position
);
this
.
current
.
attributes
.
color
.
needsUpdate
=
true
;
this
.
current
.
attributes
.
color
.
needsUpdate
=
true
;
this
.
current
.
attributes
.
normal
.
needsUpdate
=
true
;
this
.
current
.
attributes
.
normal
.
needsUpdate
=
true
;
this
.
current
.
attributes
.
position
.
needsUpdate
=
true
;
this
.
current
.
attributes
.
position
.
needsUpdate
=
true
;
this
.
current
.
attributes
.
uv
.
needsUpdate
=
true
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment