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
7c2dc38b
Commit
7c2dc38b
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
cleanup, fix test
parent
0739a5e6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-gl/_spec/renderable.spec.ts
+4
-6
4 additions, 6 deletions
src/mol-gl/_spec/renderable.spec.ts
src/mol-gl/renderable.ts
+2
-7
2 additions, 7 deletions
src/mol-gl/renderable.ts
src/mol-gl/renderable/util.ts
+21
-7
21 additions, 7 deletions
src/mol-gl/renderable/util.ts
with
27 additions
and
20 deletions
src/mol-gl/_spec/renderable.spec.ts
+
4
−
6
View file @
7c2dc38b
...
...
@@ -29,12 +29,10 @@ describe('renderable', () => {
2
,
0
,
0
,
0
])
const
bs
=
calculateBoundingSphere
({
position
,
positionCount
:
position
.
length
/
3
,
transform
,
transformCount
:
transform
.
length
/
16
})
const
bs
=
calculateBoundingSphere
(
position
,
position
.
length
/
3
,
transform
,
transform
.
length
/
16
)
expect
(
bs
.
radius
).
toBe
(
1.5
)
expect
(
bs
.
center
).
toEqual
([
1.5
,
0.0
,
0.0
])
...
...
This diff is collapsed.
Click to expand it.
src/mol-gl/renderable.ts
+
2
−
7
View file @
7c2dc38b
...
...
@@ -8,7 +8,7 @@ import { Program } from './webgl/program';
import
{
RenderableValues
,
Values
,
RenderableSchema
,
BaseValues
}
from
'
./renderable/schema
'
;
import
{
RenderVariant
,
RenderItem
}
from
'
./webgl/render-item
'
;
import
{
Sphere3D
}
from
'
mol-math/geometry
'
;
import
{
calculateBoundingSphere
}
from
'
./renderable/util
'
;
import
{
calculateBoundingSphere
FromValues
}
from
'
./renderable/util
'
;
export
type
RenderableState
=
{
visible
:
boolean
...
...
@@ -27,11 +27,6 @@ export interface Renderable<T extends RenderableValues & BaseValues> {
}
export
function
createRenderable
<
T
extends
Values
<
RenderableSchema
>
&
BaseValues
>
(
renderItem
:
RenderItem
,
values
:
T
,
state
:
RenderableState
):
Renderable
<
T
>
{
const
position
=
values
.
aPosition
.
ref
.
value
const
transform
=
values
.
aTransform
.
ref
.
value
const
positionCount
=
values
.
drawCount
.
ref
.
value
/
3
/
3
const
transformCount
=
values
.
instanceCount
.
ref
.
value
let
boundingSphere
:
Sphere3D
|
undefined
return
{
...
...
@@ -39,7 +34,7 @@ export function createRenderable<T extends Values<RenderableSchema> & BaseValues
get
state
()
{
return
state
},
get
boundingSphere
()
{
if
(
boundingSphere
)
return
boundingSphere
boundingSphere
=
calculateBoundingSphere
({
position
,
positionCount
,
transform
,
transformCount
}
)
boundingSphere
=
calculateBoundingSphere
FromValues
(
values
)
return
boundingSphere
},
...
...
This diff is collapsed.
Click to expand it.
src/mol-gl/renderable/util.ts
+
21
−
7
View file @
7c2dc38b
...
...
@@ -6,6 +6,7 @@
import
{
Sphere3D
}
from
'
mol-math/geometry
'
import
{
Mat4
,
Vec3
}
from
'
mol-math/linear-algebra
'
import
{
ValueCell
}
from
'
mol-util
'
;
export
function
calculateTextureInfo
(
n
:
number
,
itemSize
:
number
)
{
const
sqN
=
Math
.
sqrt
(
n
*
itemSize
)
...
...
@@ -32,15 +33,28 @@ export function fillSerial<T extends Helpers.NumberArray> (array: T) {
return
array
}
export
interface
Position
Data
{
p
osition
:
Float32Array
positionCount
:
number
,
t
ransform
:
Float32Array
,
transformCount
:
number
,
export
interface
Position
Values
{
aP
osition
:
ValueCell
<
Float32Array
>
drawCount
:
ValueCell
<
number
>
,
aT
ransform
:
ValueCell
<
Float32Array
>
,
instanceCount
:
ValueCell
<
number
>
,
}
export
function
calculateBoundingSphere
(
data
:
PositionData
):
Sphere3D
{
const
{
position
,
positionCount
,
transform
,
transformCount
}
=
data
function
getPositionDataFromValues
(
values
:
PositionValues
)
{
return
{
position
:
values
.
aPosition
.
ref
.
value
,
positionCount
:
values
.
drawCount
.
ref
.
value
/
3
/
3
,
transform
:
values
.
aTransform
.
ref
.
value
,
transformCount
:
values
.
instanceCount
.
ref
.
value
}
}
export
function
calculateBoundingSphereFromValues
(
values
:
PositionValues
){
const
{
position
,
positionCount
,
transform
,
transformCount
}
=
getPositionDataFromValues
(
values
)
return
calculateBoundingSphere
(
position
,
positionCount
,
transform
,
transformCount
)
}
export
function
calculateBoundingSphere
(
position
:
Float32Array
,
positionCount
:
number
,
transform
:
Float32Array
,
transformCount
:
number
):
Sphere3D
{
const
m
=
Mat4
.
zero
()
...
...
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