Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Michal Malý
Molstar
Commits
9cfdabb1
Commit
9cfdabb1
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
ensure normalBuffer is zero'ed out; update cell after transform
parent
5a3364fb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mol-geo/mesh/mesh.ts
+18
-11
18 additions, 11 deletions
src/mol-geo/mesh/mesh.ts
with
18 additions
and
11 deletions
src/mol-geo/mesh/mesh.ts
+
18
−
11
View file @
9cfdabb1
...
@@ -49,16 +49,22 @@ export namespace Mesh {
...
@@ -49,16 +49,22 @@ export namespace Mesh {
}
}
}
}
export
function
computeNormalsImmediate
(
surface
:
Mesh
)
{
export
function
computeNormalsImmediate
(
mesh
:
Mesh
)
{
if
(
surface
.
normalsComputed
)
return
;
if
(
mesh
.
normalsComputed
)
return
;
const
normals
=
surface
.
normalBuffer
.
ref
.
value
.
length
>=
surface
.
vertexCount
*
3
const
normals
=
mesh
.
normalBuffer
.
ref
.
value
.
length
>=
mesh
.
vertexCount
*
3
?
surface
.
normalBuffer
.
ref
.
value
:
new
Float32Array
(
surface
.
vertexBuffer
.
ref
.
value
.
length
);
?
mesh
.
normalBuffer
.
ref
.
value
:
new
Float32Array
(
mesh
.
vertexBuffer
.
ref
.
value
.
length
);
const
v
=
surface
.
vertexBuffer
.
ref
.
value
,
triangles
=
surface
.
indexBuffer
.
ref
.
value
;
const
v
=
mesh
.
vertexBuffer
.
ref
.
value
,
triangles
=
mesh
.
indexBuffer
.
ref
.
value
;
if
(
normals
===
mesh
.
normalBuffer
.
ref
.
value
)
{
for
(
let
i
=
0
,
ii
=
3
*
mesh
.
vertexCount
;
i
<
ii
;
i
+=
3
)
{
normals
[
i
]
=
0
;
normals
[
i
+
1
]
=
0
;
normals
[
i
+
2
]
=
0
;
}
}
const
x
=
Vec3
.
zero
(),
y
=
Vec3
.
zero
(),
z
=
Vec3
.
zero
(),
d1
=
Vec3
.
zero
(),
d2
=
Vec3
.
zero
(),
n
=
Vec3
.
zero
();
const
x
=
Vec3
.
zero
(),
y
=
Vec3
.
zero
(),
z
=
Vec3
.
zero
(),
d1
=
Vec3
.
zero
(),
d2
=
Vec3
.
zero
(),
n
=
Vec3
.
zero
();
for
(
let
i
=
0
,
ii
=
3
*
surface
.
triangleCount
;
i
<
ii
;
i
+=
3
)
{
for
(
let
i
=
0
,
ii
=
3
*
mesh
.
triangleCount
;
i
<
ii
;
i
+=
3
)
{
const
a
=
3
*
triangles
[
i
],
b
=
3
*
triangles
[
i
+
1
],
c
=
3
*
triangles
[
i
+
2
];
const
a
=
3
*
triangles
[
i
],
b
=
3
*
triangles
[
i
+
1
],
c
=
3
*
triangles
[
i
+
2
];
Vec3
.
fromArray
(
x
,
v
,
a
);
Vec3
.
fromArray
(
x
,
v
,
a
);
...
@@ -73,7 +79,7 @@ export namespace Mesh {
...
@@ -73,7 +79,7 @@ export namespace Mesh {
normals
[
c
]
+=
n
[
0
];
normals
[
c
+
1
]
+=
n
[
1
];
normals
[
c
+
2
]
+=
n
[
2
];
normals
[
c
]
+=
n
[
0
];
normals
[
c
+
1
]
+=
n
[
1
];
normals
[
c
+
2
]
+=
n
[
2
];
}
}
for
(
let
i
=
0
,
ii
=
3
*
surface
.
vertexCount
;
i
<
ii
;
i
+=
3
)
{
for
(
let
i
=
0
,
ii
=
3
*
mesh
.
vertexCount
;
i
<
ii
;
i
+=
3
)
{
const
nx
=
normals
[
i
];
const
nx
=
normals
[
i
];
const
ny
=
normals
[
i
+
1
];
const
ny
=
normals
[
i
+
1
];
const
nz
=
normals
[
i
+
2
];
const
nz
=
normals
[
i
+
2
];
...
@@ -82,8 +88,8 @@ export namespace Mesh {
...
@@ -82,8 +88,8 @@ export namespace Mesh {
// console.log([normals[i], normals[i + 1], normals[i + 2]], [v[i], v[i + 1], v[i + 2]])
// console.log([normals[i], normals[i + 1], normals[i + 2]], [v[i], v[i + 1], v[i + 2]])
}
}
ValueCell
.
update
(
surface
.
normalBuffer
,
normals
);
ValueCell
.
update
(
mesh
.
normalBuffer
,
normals
);
surface
.
normalsComputed
=
true
;
mesh
.
normalsComputed
=
true
;
}
}
export
function
computeNormals
(
surface
:
Mesh
):
Task
<
Mesh
>
{
export
function
computeNormals
(
surface
:
Mesh
):
Task
<
Mesh
>
{
...
@@ -101,15 +107,16 @@ export namespace Mesh {
...
@@ -101,15 +107,16 @@ export namespace Mesh {
}
}
export
function
transformRangeImmediate
(
mesh
:
Mesh
,
t
:
Mat4
,
offset
:
number
,
count
:
number
)
{
export
function
transformRangeImmediate
(
mesh
:
Mesh
,
t
:
Mat4
,
offset
:
number
,
count
:
number
)
{
transformPositionArray
(
t
,
mesh
.
vertexBuffer
.
ref
.
value
,
offset
,
count
)
const
v
=
mesh
.
vertexBuffer
.
ref
.
value
transformPositionArray
(
t
,
v
,
offset
,
count
)
// TODO normals transformation does not work for an unknown reason, ASR
// TODO normals transformation does not work for an unknown reason, ASR
// if (mesh.normalBuffer.ref.value) {
// if (mesh.normalBuffer.ref.value) {
// const n = getNormalMatrix(Mat3.zero(), t)
// const n = getNormalMatrix(Mat3.zero(), t)
// transformDirectionArray(n, mesh.normalBuffer.ref.value, offset, count)
// transformDirectionArray(n, mesh.normalBuffer.ref.value, offset, count)
// mesh.normalsComputed = true;
// mesh.normalsComputed = true;
// }
// }
ValueCell
.
update
(
mesh
.
vertexBuffer
,
v
);
mesh
.
normalsComputed
=
false
;
mesh
.
normalsComputed
=
false
;
// mesh.boundingSphere = void 0;
}
}
export
function
computeBoundingSphere
(
mesh
:
Mesh
):
Task
<
Mesh
>
{
export
function
computeBoundingSphere
(
mesh
:
Mesh
):
Task
<
Mesh
>
{
...
...
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