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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
b7b28227
Commit
b7b28227
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
MeshBuilder.addCage
parent
9ae33e79
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-geo/geometry/lines/lines-builder.ts
+7
-7
7 additions, 7 deletions
src/mol-geo/geometry/lines/lines-builder.ts
src/mol-geo/geometry/mesh/mesh-builder.ts
+20
-1
20 additions, 1 deletion
src/mol-geo/geometry/mesh/mesh-builder.ts
with
27 additions
and
8 deletions
src/mol-geo/geometry/lines/lines-builder.ts
+
7
−
7
View file @
b7b28227
...
@@ -16,8 +16,8 @@ export interface LinesBuilder {
...
@@ -16,8 +16,8 @@ export interface LinesBuilder {
getLines
():
Lines
getLines
():
Lines
}
}
const
tmpA
=
Vec3
.
zero
()
const
tmp
Vec
A
=
Vec3
.
zero
()
const
tmpB
=
Vec3
.
zero
()
const
tmp
Vec
B
=
Vec3
.
zero
()
export
namespace
LinesBuilder
{
export
namespace
LinesBuilder
{
export
function
create
(
initialCount
=
2048
,
chunkSize
=
1024
,
lines
?:
Lines
):
LinesBuilder
{
export
function
create
(
initialCount
=
2048
,
chunkSize
=
1024
,
lines
?:
Lines
):
LinesBuilder
{
...
@@ -47,11 +47,11 @@ export namespace LinesBuilder {
...
@@ -47,11 +47,11 @@ export namespace LinesBuilder {
addCage
:
(
t
:
Mat4
,
cage
:
Cage
,
group
:
number
)
=>
{
addCage
:
(
t
:
Mat4
,
cage
:
Cage
,
group
:
number
)
=>
{
const
{
vertices
,
edges
}
=
cage
const
{
vertices
,
edges
}
=
cage
for
(
let
i
=
0
,
il
=
edges
.
length
;
i
<
il
;
i
+=
2
)
{
for
(
let
i
=
0
,
il
=
edges
.
length
;
i
<
il
;
i
+=
2
)
{
Vec3
.
fromArray
(
tmpA
,
vertices
,
edges
[
i
]
*
3
)
Vec3
.
fromArray
(
tmp
Vec
A
,
vertices
,
edges
[
i
]
*
3
)
Vec3
.
fromArray
(
tmpB
,
vertices
,
edges
[
i
+
1
]
*
3
)
Vec3
.
fromArray
(
tmp
Vec
B
,
vertices
,
edges
[
i
+
1
]
*
3
)
Vec3
.
transformMat4
(
tmpA
,
tmpA
,
t
)
Vec3
.
transformMat4
(
tmp
Vec
A
,
tmp
Vec
A
,
t
)
Vec3
.
transformMat4
(
tmpB
,
tmpB
,
t
)
Vec3
.
transformMat4
(
tmp
Vec
B
,
tmp
Vec
B
,
t
)
add
(
tmpA
[
0
],
tmpA
[
1
],
tmpA
[
2
],
tmpB
[
0
],
tmpB
[
1
],
tmpB
[
2
],
group
)
add
(
tmp
Vec
A
[
0
],
tmp
Vec
A
[
1
],
tmp
Vec
A
[
2
],
tmp
Vec
B
[
0
],
tmp
Vec
B
[
1
],
tmp
Vec
B
[
2
],
group
)
}
}
},
},
getLines
:
()
=>
{
getLines
:
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/mol-geo/geometry/mesh/mesh-builder.ts
+
20
−
1
View file @
b7b28227
/**
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018
-2019
mol* contributors, licensed under MIT, See LICENSE file for more info.
*
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
*/
...
@@ -10,9 +10,14 @@ import { ChunkedArray } from 'mol-data/util';
...
@@ -10,9 +10,14 @@ import { ChunkedArray } from 'mol-data/util';
import
{
Mesh
}
from
'
./mesh
'
;
import
{
Mesh
}
from
'
./mesh
'
;
import
{
getNormalMatrix
}
from
'
../../util
'
;
import
{
getNormalMatrix
}
from
'
../../util
'
;
import
{
Primitive
}
from
'
../../primitive/primitive
'
;
import
{
Primitive
}
from
'
../../primitive/primitive
'
;
import
{
Cage
}
from
'
mol-geo/primitive/cage
'
;
import
{
addSphere
}
from
'
./builder/sphere
'
;
import
{
addCylinder
}
from
'
./builder/cylinder
'
;
const
tmpV
=
Vec3
.
zero
()
const
tmpV
=
Vec3
.
zero
()
const
tmpMat3
=
Mat3
.
zero
()
const
tmpMat3
=
Mat3
.
zero
()
const
tmpVecA
=
Vec3
.
zero
()
const
tmpVecB
=
Vec3
.
zero
()
export
namespace
MeshBuilder
{
export
namespace
MeshBuilder
{
export
interface
State
{
export
interface
State
{
...
@@ -55,6 +60,20 @@ export namespace MeshBuilder {
...
@@ -55,6 +60,20 @@ export namespace MeshBuilder {
}
}
}
}
export
function
addCage
(
state
:
State
,
t
:
Mat4
,
cage
:
Cage
,
radius
:
number
,
detail
:
number
)
{
const
{
vertices
:
va
,
edges
:
ea
}
=
cage
const
cylinderProps
=
{
radiusTop
:
radius
,
radiusBottom
:
radius
}
for
(
let
i
=
0
,
il
=
ea
.
length
;
i
<
il
;
i
+=
2
)
{
Vec3
.
fromArray
(
tmpVecA
,
va
,
ea
[
i
]
*
3
)
Vec3
.
fromArray
(
tmpVecB
,
va
,
ea
[
i
+
1
]
*
3
)
Vec3
.
transformMat4
(
tmpVecA
,
tmpVecA
,
t
)
Vec3
.
transformMat4
(
tmpVecB
,
tmpVecB
,
t
)
addSphere
(
state
,
tmpVecA
,
radius
,
detail
)
addSphere
(
state
,
tmpVecB
,
radius
,
detail
)
addCylinder
(
state
,
tmpVecA
,
tmpVecB
,
1
,
cylinderProps
)
}
}
export
function
getMesh
(
state
:
State
):
Mesh
{
export
function
getMesh
(
state
:
State
):
Mesh
{
const
{
vertices
,
normals
,
indices
,
groups
,
mesh
}
=
state
const
{
vertices
,
normals
,
indices
,
groups
,
mesh
}
=
state
const
vb
=
ChunkedArray
.
compact
(
vertices
,
true
)
as
Float32Array
const
vb
=
ChunkedArray
.
compact
(
vertices
,
true
)
as
Float32Array
...
...
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