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
fc0ca27a
Commit
fc0ca27a
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
volume repr refactoring cont'd
parent
918fceea
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-repr/volume/direct-volume.ts
+28
-76
28 additions, 76 deletions
src/mol-repr/volume/direct-volume.ts
src/mol-repr/volume/isosurface-mesh.ts
+1
-1
1 addition, 1 deletion
src/mol-repr/volume/isosurface-mesh.ts
with
29 additions
and
77 deletions
src/mol-repr/volume/direct-volume.ts
+
28
−
76
View file @
fc0ca27a
...
...
@@ -7,7 +7,7 @@
import
{
VolumeData
}
from
'
mol-model/volume
'
import
{
RuntimeContext
}
from
'
mol-task
'
import
{
VolumeVisual
,
VolumeRepresentation
}
from
'
./index
'
;
import
{
DirectVolumeRenderObject
,
createDirectVolumeRenderObject
}
from
'
mol-gl/render-object
'
;
import
{
createDirectVolumeRenderObject
}
from
'
mol-gl/render-object
'
;
import
{
Loci
,
EmptyLoci
}
from
'
mol-model/loci
'
;
import
{
paramDefaultValues
}
from
'
mol-util/parameter
'
;
import
{
Vec3
,
Mat4
}
from
'
mol-math/linear-algebra
'
;
...
...
@@ -15,12 +15,12 @@ import { Box3D } from 'mol-math/geometry';
import
{
WebGLContext
}
from
'
mol-gl/webgl/context
'
;
import
{
createTexture
}
from
'
mol-gl/webgl/texture
'
;
import
{
LocationIterator
}
from
'
mol-geo/util/location-iterator
'
;
import
{
NullLocation
}
from
'
mol-model/location
'
;
import
{
createIdentityTransform
}
from
'
mol-geo/geometry/transform-data
'
;
import
{
DirectVolume
}
from
'
mol-geo/geometry/direct-volume/direct-volume
'
;
import
{
Geometry
,
createRenderableState
,
updateRenderableState
}
from
'
mol-geo/geometry/geometry
'
;
import
{
Geometry
,
createRenderableState
}
from
'
mol-geo/geometry/geometry
'
;
import
{
PickingId
}
from
'
mol-geo/geometry/picking
'
;
import
{
MarkerAction
}
from
'
mol-geo/geometry/marker-data
'
;
import
{
VisualUpdateState
}
from
'
mol-repr/util
'
;
function
getBoundingBox
(
gridDimension
:
Vec3
,
transform
:
Mat4
)
{
const
bbox
=
Box3D
.
empty
()
...
...
@@ -168,6 +168,18 @@ export function createDirectVolume3d(ctx: RuntimeContext, webgl: WebGLContext, v
return
DirectVolume
.
create
(
bbox
,
gridDimension
,
transform
,
texture
,
directVolume
)
}
//
export
async
function
createDirectVolume
(
ctx
:
RuntimeContext
,
volume
:
VolumeData
,
props
:
DirectVolumeProps
,
directVolume
?:
DirectVolume
)
{
const
{
webgl
}
=
props
if
(
webgl
===
undefined
)
throw
new
Error
(
'
DirectVolumeVisual requires `webgl` in props
'
)
return
webgl
.
isWebGL2
?
await
createDirectVolume3d
(
ctx
,
webgl
,
volume
,
directVolume
)
:
await
createDirectVolume2d
(
ctx
,
webgl
,
volume
,
directVolume
)
}
//
export
const
DirectVolumeParams
=
{
...
...
@@ -178,81 +190,21 @@ export const DefaultDirectVolumeProps = paramDefaultValues(DirectVolumeParams)
export
type
DirectVolumeProps
=
typeof
DefaultDirectVolumeProps
export
function
DirectVolumeVisual
():
VolumeVisual
<
DirectVolumeProps
>
{
let
currentProps
=
DefaultDirectVolumeProps
let
renderObject
:
DirectVolumeRenderObject
let
currentVolume
:
VolumeData
let
directVolume
:
DirectVolume
async
function
create
(
ctx
:
RuntimeContext
,
volume
:
VolumeData
,
props
:
Partial
<
DirectVolumeProps
>
=
{})
{
const
{
webgl
}
=
props
if
(
webgl
===
undefined
)
throw
new
Error
(
'
DirectVolumeVisual requires `webgl` in props
'
)
currentProps
=
{
...
DefaultDirectVolumeProps
,
...
props
}
if
(
props
.
isoValueRelative
)
{
// currentProps.isoValueAbsolute = VolumeIsoValue.calcAbsolute(currentVolume.dataStats, props.isoValueRelative)
}
const
state
=
createRenderableState
(
currentProps
)
const
locationIt
=
LocationIterator
(
1
,
1
,
()
=>
NullLocation
)
const
transform
=
createIdentityTransform
()
if
(
webgl
.
isWebGL2
)
{
directVolume
=
await
createDirectVolume3d
(
ctx
,
webgl
,
volume
,
directVolume
)
const
values
=
await
DirectVolume
.
createValues
(
ctx
,
directVolume
,
transform
,
locationIt
,
currentProps
)
renderObject
=
createDirectVolumeRenderObject
(
values
,
state
)
}
else
{
directVolume
=
await
createDirectVolume2d
(
ctx
,
webgl
,
volume
,
directVolume
)
const
values
=
await
DirectVolume
.
createValues
(
ctx
,
directVolume
,
transform
,
locationIt
,
currentProps
)
renderObject
=
createDirectVolumeRenderObject
(
values
,
state
)
}
}
async
function
update
(
ctx
:
RuntimeContext
,
props
:
Partial
<
DirectVolumeProps
>
=
{})
{
const
{
webgl
}
=
props
if
(
webgl
===
undefined
)
throw
new
Error
(
'
DirectVolumeVisual requires `webgl` in props
'
)
const
newProps
=
{
...
currentProps
,
...
props
}
if
(
props
.
isoValueRelative
)
{
// newProps.isoValueAbsolute = VolumeIsoValue.calcAbsolute(currentVolume.dataStats, props.isoValueRelative)
}
console
.
log
(
'
newProps.isoValueAbsolute
'
,
newProps
.
isoValueAbsolute
)
DirectVolume
.
updateValues
(
renderObject
.
values
,
newProps
)
updateRenderableState
(
renderObject
.
state
,
newProps
)
currentProps
=
newProps
}
return
{
get
renderObject
()
{
return
renderObject
},
async
createOrUpdate
(
ctx
:
RuntimeContext
,
props
:
Partial
<
DirectVolumeProps
>
=
{},
volume
?:
VolumeData
)
{
if
(
!
volume
&&
!
currentVolume
)
{
throw
new
Error
(
'
missing volume
'
)
}
else
if
(
volume
&&
(
!
currentVolume
||
!
renderObject
))
{
currentVolume
=
volume
await
create
(
ctx
,
volume
,
props
)
}
else
if
(
volume
&&
volume
!==
currentVolume
)
{
currentVolume
=
volume
await
create
(
ctx
,
volume
,
props
)
}
else
{
await
update
(
ctx
,
props
)
}
currentProps
=
{
...
DefaultDirectVolumeProps
,
...
props
}
},
getLoci
(
pickingId
:
PickingId
)
{
// TODO
return
EmptyLoci
return
VolumeVisual
<
DirectVolumeProps
>
({
defaultProps
:
DefaultDirectVolumeProps
,
createGeometry
:
createDirectVolume
,
getLoci
:
()
=>
EmptyLoci
,
mark
:
()
=>
false
,
setUpdateState
:
(
state
:
VisualUpdateState
,
newProps
:
DirectVolumeProps
,
currentProps
:
DirectVolumeProps
)
=>
{
},
mark
(
loci
:
Loci
,
action
:
MarkerAction
)
{
// TODO
return
false
createRenderObject
:
async
(
ctx
:
RuntimeContext
,
geometry
:
DirectVolume
,
locationIt
:
LocationIterator
,
props
:
DirectVolumeProps
)
=>
{
const
transform
=
createIdentityTransform
()
const
values
=
await
DirectVolume
.
createValues
(
ctx
,
geometry
,
transform
,
locationIt
,
props
)
const
state
=
createRenderableState
(
props
)
return
createDirectVolumeRenderObject
(
values
,
state
)
},
destroy
()
{
// TODO
}
}
updateValues
:
DirectVolume
.
updateValues
})
}
export
function
DirectVolumeRepresentation
():
VolumeRepresentation
<
DirectVolumeProps
>
{
...
...
This diff is collapsed.
Click to expand it.
src/mol-repr/volume/isosurface-mesh.ts
+
1
−
1
View file @
fc0ca27a
...
...
@@ -48,7 +48,7 @@ export const IsosurfaceParams = {
export
const
DefaultIsosurfaceProps
=
paramDefaultValues
(
IsosurfaceParams
)
export
type
IsosurfaceProps
=
typeof
DefaultIsosurfaceProps
export
function
IsosurfaceVisual
():
VolumeVisual
<
IsosurfaceProps
>
{
export
function
IsosurfaceVisual
():
VolumeVisual
<
IsosurfaceProps
>
{
return
VolumeVisual
<
IsosurfaceProps
>
({
defaultProps
:
DefaultIsosurfaceProps
,
createGeometry
:
createVolumeIsosurface
,
...
...
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