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
0e07062b
Commit
0e07062b
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
added color to bounding sphere helper
parent
0815ca69
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-canvas3d/helper/bounding-sphere-helper.ts
+9
-7
9 additions, 7 deletions
src/mol-canvas3d/helper/bounding-sphere-helper.ts
src/mol-geo/geometry/mesh/mesh.ts
+3
-4
3 additions, 4 deletions
src/mol-geo/geometry/mesh/mesh.ts
with
12 additions
and
11 deletions
src/mol-canvas3d/helper/bounding-sphere-helper.ts
+
9
−
7
View file @
0e07062b
...
...
@@ -13,6 +13,8 @@ import Scene from 'mol-gl/scene';
import
{
WebGLContext
}
from
'
mol-gl/webgl/context
'
;
import
{
Sphere3D
}
from
'
mol-math/geometry
'
;
import
{
Vec3
,
Mat4
}
from
'
mol-math/linear-algebra
'
;
import
{
Color
}
from
'
mol-util/color
'
;
import
{
ColorNames
}
from
'
mol-util/color/tables
'
;
export
const
DebugHelperParams
=
{
sceneBoundingSpheres
:
PD
.
Boolean
(
false
,
{
description
:
'
Show scene bounding spheres.
'
}),
...
...
@@ -39,18 +41,18 @@ export class BoundingSphereHelper {
}
update
()
{
const
newSceneData
=
updateBoundingSphereData
(
this
.
scene
,
this
.
parent
.
boundingSphere
,
this
.
sceneData
)
const
newSceneData
=
updateBoundingSphereData
(
this
.
scene
,
this
.
parent
.
boundingSphere
,
this
.
sceneData
,
ColorNames
.
grey
)
if
(
newSceneData
)
this
.
sceneData
=
newSceneData
const
oldRO
=
new
Set
<
RenderObject
>
()
this
.
parent
.
forEach
((
r
,
ro
)
=>
{
const
objectData
=
this
.
objectsData
.
get
(
ro
)
const
newObjectData
=
updateBoundingSphereData
(
this
.
scene
,
r
.
boundingSphere
,
objectData
)
const
newObjectData
=
updateBoundingSphereData
(
this
.
scene
,
r
.
boundingSphere
,
objectData
,
ColorNames
.
tomato
)
if
(
newObjectData
)
this
.
objectsData
.
set
(
ro
,
newObjectData
)
if
(
ro
.
type
===
'
mesh
'
||
ro
.
type
===
'
lines
'
||
ro
.
type
===
'
points
'
)
{
const
instanceData
=
this
.
instancesData
.
get
(
ro
)
const
newInstanceData
=
updateBoundingSphereData
(
this
.
scene
,
ro
.
values
.
invariantBoundingSphere
.
ref
.
value
,
instanceData
,
ro
.
values
.
aTransform
.
ref
.
value
,
ro
.
values
.
instanceCount
.
ref
.
value
)
const
newInstanceData
=
updateBoundingSphereData
(
this
.
scene
,
ro
.
values
.
invariantBoundingSphere
.
ref
.
value
,
instanceData
,
ColorNames
.
skyblue
,
ro
.
values
.
aTransform
.
ref
.
value
,
ro
.
values
.
instanceCount
.
ref
.
value
)
if
(
newInstanceData
)
this
.
instancesData
.
set
(
ro
,
newInstanceData
)
}
...
...
@@ -96,10 +98,10 @@ export class BoundingSphereHelper {
}
}
function
updateBoundingSphereData
(
scene
:
Scene
,
boundingSphere
:
Sphere3D
,
data
:
BoundingSphereData
|
undefined
,
transform
?:
Float32Array
,
transformCount
?:
number
)
{
function
updateBoundingSphereData
(
scene
:
Scene
,
boundingSphere
:
Sphere3D
,
data
:
BoundingSphereData
|
undefined
,
color
:
Color
,
transform
?:
Float32Array
,
transformCount
?:
number
)
{
if
(
!
data
||
!
Sphere3D
.
exactEquals
(
data
.
boundingSphere
,
boundingSphere
))
{
if
(
data
)
scene
.
remove
(
data
.
renderObject
)
const
renderObject
=
createBoundingSphereRenderObject
(
boundingSphere
,
transform
,
transformCount
)
const
renderObject
=
createBoundingSphereRenderObject
(
boundingSphere
,
color
,
transform
,
transformCount
)
scene
.
add
(
renderObject
)
return
{
boundingSphere
,
renderObject
}
}
...
...
@@ -107,7 +109,7 @@ function updateBoundingSphereData(scene: Scene, boundingSphere: Sphere3D, data:
const
tmpCenter
=
Vec3
.
zero
()
const
tmpM
=
Mat4
.
identity
()
function
createBoundingSphereRenderObject
(
boundingSphere
:
Sphere3D
,
transform
?:
Float32Array
,
transformCount
?:
number
)
{
function
createBoundingSphereRenderObject
(
boundingSphere
:
Sphere3D
,
color
:
Color
,
transform
?:
Float32Array
,
transformCount
?:
number
)
{
const
builderState
=
MeshBuilder
.
createState
(
1024
,
512
)
if
(
transform
&&
transformCount
)
{
// TODO create instanced mesh?
...
...
@@ -120,6 +122,6 @@ function createBoundingSphereRenderObject(boundingSphere: Sphere3D, transform?:
if
(
boundingSphere
.
radius
)
addSphere
(
builderState
,
boundingSphere
.
center
,
boundingSphere
.
radius
,
2
)
}
const
mesh
=
MeshBuilder
.
getMesh
(
builderState
)
const
values
=
Mesh
.
createValuesSimple
(
mesh
,
{
alpha
:
0.1
,
doubleSided
:
false
})
const
values
=
Mesh
.
createValuesSimple
(
mesh
,
{
alpha
:
0.1
,
doubleSided
:
false
}
,
color
)
return
createMeshRenderObject
(
values
,
{
visible
:
true
,
pickable
:
false
,
opaque
:
false
})
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-geo/geometry/mesh/mesh.ts
+
3
−
4
View file @
0e07062b
...
...
@@ -19,8 +19,7 @@ import { ParamDefinition as PD } from 'mol-util/param-definition';
import
{
calculateBoundingSphere
}
from
'
mol-gl/renderable/util
'
;
import
{
Theme
}
from
'
mol-theme/theme
'
;
import
{
MeshValues
}
from
'
mol-gl/renderable/mesh
'
;
import
{
ColorTheme
}
from
'
mol-theme/color
'
;
import
{
NullLocation
}
from
'
mol-model/location
'
;
import
{
ColorNames
}
from
'
mol-util/color/tables
'
;
export
interface
Mesh
{
readonly
kind
:
'
mesh
'
,
...
...
@@ -379,10 +378,10 @@ export namespace Mesh {
}
}
export
function
createValuesSimple
(
mesh
:
Mesh
,
props
:
Partial
<
PD
.
Values
<
Params
>>
):
MeshValues
{
export
function
createValuesSimple
(
mesh
:
Mesh
,
props
:
Partial
<
PD
.
Values
<
Params
>>
,
colorValue
=
ColorNames
.
grey
):
MeshValues
{
const
p
=
{
...
PD
.
getDefaultValues
(
Params
),
...
props
}
const
transform
=
createIdentityTransform
()
const
color
=
createValueColor
(
ColorTheme
.
Empty
.
color
(
NullLocation
,
f
al
s
e
)
)
const
color
=
createValueColor
(
colorV
al
u
e
)
const
marker
=
createMarkers
(
1
)
const
counts
=
{
drawCount
:
mesh
.
triangleCount
*
3
,
groupCount
:
1
,
instanceCount
:
1
}
...
...
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