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
c72f16cc
Commit
c72f16cc
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
use PlyData directly
parent
8e296fd0
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-model-formats/shape/ply.ts
+13
-39
13 additions, 39 deletions
src/mol-model-formats/shape/ply.ts
with
13 additions
and
39 deletions
src/mol-model-formats/shape/ply.ts
+
13
−
39
View file @
c72f16cc
...
...
@@ -14,36 +14,6 @@ import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder';
import
{
Mesh
}
from
'
mol-geo/geometry/mesh/mesh
'
;
import
{
Shape
}
from
'
mol-model/shape
'
;
interface
PlyShapeData
{
centers
:
number
[],
normals
:
number
[],
faces
:
number
[],
colors
:
Color
[],
labels
:
string
[],
}
function
collectData_for_Shape
(
parsedData
:
PlyData
):
PlyShapeData
{
// parsedData.data.PLY_File. to access So.format.Ply
console
.
log
(
'
parsedData
'
,
parsedData
)
const
{
vertices
,
colors
,
faces
,
normals
}
=
parsedData
const
data
:
PlyShapeData
=
{
centers
:
vertices
,
normals
:
normals
,
faces
:
faces
,
colors
:
[],
labels
:
[],
}
for
(
let
i
=
0
;
i
<
parsedData
.
faceCount
;
i
++
)
{
data
.
colors
[
i
]
=
Color
.
fromRgb
(
colors
[
faces
[
4
*
i
+
1
]
*
3
+
0
],
colors
[
faces
[
4
*
i
+
1
]
*
3
+
1
],
colors
[
faces
[
4
*
i
+
1
]
*
3
+
2
]);
data
.
labels
[
i
]
=
parsedData
.
properties
[
parsedData
.
propertyCount
*
faces
[
4
*
i
+
1
]
+
10
].
toString
();
// i.toString();
// data.transforms[i] = 0;
}
console
.
log
(
'
data
'
,
data
);
return
data
;
}
async
function
getPlyMesh
(
ctx
:
RuntimeContext
,
centers
:
number
[],
normals
:
number
[],
faces
:
number
[],
mesh
?:
Mesh
)
{
const
builderState
=
MeshBuilder
.
createState
(
faces
.
length
,
faces
.
length
,
mesh
)
builderState
.
currentGroup
=
0
...
...
@@ -64,22 +34,26 @@ async function getPlyMesh(ctx: RuntimeContext, centers: number[], normals: numbe
// console.log(triangle_vertices)
addTriangle
(
builderState
,
triangle_vertices
,
triangle_normals
,
triangle_indices
)
}
let
a
=
MeshBuilder
.
getMesh
(
builderState
);
console
.
log
(
a
);
return
a
return
MeshBuilder
.
getMesh
(
builderState
);
}
async
function
getShape
(
ctx
:
RuntimeContext
,
parsedData
:
PlyData
,
props
:
{},
shape
?:
Shape
<
Mesh
>
)
{
const
data
=
collectData_for_Shape
(
parsedData
)
await
ctx
.
update
(
'
async creation of shape from myData
'
)
const
{
centers
,
normals
,
faces
,
colors
,
labels
}
=
data
const
mesh
=
await
getPlyMesh
(
ctx
,
centers
,
normals
,
faces
,
shape
&&
shape
.
geometry
)
const
groupCount
=
centers
.
length
/
3
const
{
vertices
,
normals
,
faces
,
colors
,
properties
}
=
parsedData
const
mesh
=
await
getPlyMesh
(
ctx
,
vertices
,
normals
,
faces
,
shape
&&
shape
.
geometry
)
return
shape
||
Shape
.
create
(
'
test
'
,
mesh
,
(
groupId
:
number
)
=>
colors
[
groupId
],
// color: per group, same for instances
(
groupId
:
number
)
=>
{
return
Color
.
fromRgb
(
colors
[
faces
[
4
*
groupId
+
1
]
*
3
+
0
],
colors
[
faces
[
4
*
groupId
+
1
]
*
3
+
1
],
colors
[
faces
[
4
*
groupId
+
1
]
*
3
+
2
]
)
},
()
=>
1
,
// size: constant
(
groupId
:
number
,
instanceId
:
number
)
=>
labels
[
instanceId
*
groupCount
+
groupId
]
// label: per group and instance
(
groupId
:
number
)
=>
{
return
properties
[
parsedData
.
propertyCount
*
faces
[
4
*
groupId
+
1
]
+
10
].
toString
()
}
)
}
...
...
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