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
9ae27784
Commit
9ae27784
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
avoid getters on renderable objects
parent
a16b1d59
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-canvas3d/helper/bounding-sphere-helper.ts
+2
-2
2 additions, 2 deletions
src/mol-canvas3d/helper/bounding-sphere-helper.ts
src/mol-gl/renderable.ts
+0
-23
0 additions, 23 deletions
src/mol-gl/renderable.ts
src/mol-gl/scene.ts
+13
-11
13 additions, 11 deletions
src/mol-gl/scene.ts
with
15 additions
and
36 deletions
src/mol-canvas3d/helper/bounding-sphere-helper.ts
+
2
−
2
View file @
9ae27784
...
@@ -50,12 +50,12 @@ export class BoundingSphereHelper {
...
@@ -50,12 +50,12 @@ export class BoundingSphereHelper {
this
.
parent
.
forEach
((
r
,
ro
)
=>
{
this
.
parent
.
forEach
((
r
,
ro
)
=>
{
const
objectData
=
this
.
objectsData
.
get
(
ro
)
const
objectData
=
this
.
objectsData
.
get
(
ro
)
const
newObjectData
=
updateBoundingSphereData
(
this
.
scene
,
r
.
boundingSphere
,
objectData
,
ColorNames
.
tomato
)
const
newObjectData
=
updateBoundingSphereData
(
this
.
scene
,
r
.
values
.
boundingSphere
.
ref
.
value
,
objectData
,
ColorNames
.
tomato
)
if
(
newObjectData
)
this
.
objectsData
.
set
(
ro
,
newObjectData
)
if
(
newObjectData
)
this
.
objectsData
.
set
(
ro
,
newObjectData
)
if
(
ro
.
type
===
'
mesh
'
||
ro
.
type
===
'
lines
'
||
ro
.
type
===
'
points
'
)
{
if
(
ro
.
type
===
'
mesh
'
||
ro
.
type
===
'
lines
'
||
ro
.
type
===
'
points
'
)
{
const
instanceData
=
this
.
instancesData
.
get
(
ro
)
const
instanceData
=
this
.
instancesData
.
get
(
ro
)
const
newInstanceData
=
updateBoundingSphereData
(
this
.
scene
,
r
.
invariantBoundingSphere
,
instanceData
,
ColorNames
.
skyblue
,
{
const
newInstanceData
=
updateBoundingSphereData
(
this
.
scene
,
r
.
values
.
invariantBoundingSphere
.
ref
.
value
,
instanceData
,
ColorNames
.
skyblue
,
{
aTransform
:
ro
.
values
.
aTransform
,
aTransform
:
ro
.
values
.
aTransform
,
transform
:
ro
.
values
.
transform
,
transform
:
ro
.
values
.
transform
,
uInstanceCount
:
ro
.
values
.
uInstanceCount
,
uInstanceCount
:
ro
.
values
.
uInstanceCount
,
...
...
This diff is collapsed.
Click to expand it.
src/mol-gl/renderable.ts
+
0
−
23
View file @
9ae27784
...
@@ -7,8 +7,6 @@
...
@@ -7,8 +7,6 @@
import
{
Program
}
from
'
./webgl/program
'
;
import
{
Program
}
from
'
./webgl/program
'
;
import
{
RenderableValues
,
Values
,
RenderableSchema
}
from
'
./renderable/schema
'
;
import
{
RenderableValues
,
Values
,
RenderableSchema
}
from
'
./renderable/schema
'
;
import
{
RenderVariant
,
RenderItem
}
from
'
./webgl/render-item
'
;
import
{
RenderVariant
,
RenderItem
}
from
'
./webgl/render-item
'
;
import
{
Sphere3D
}
from
'
mol-math/geometry
'
;
import
{
Vec3
}
from
'
mol-math/linear-algebra
'
;
import
{
ValueCell
}
from
'
mol-util
'
;
import
{
ValueCell
}
from
'
mol-util
'
;
import
{
idFactory
}
from
'
mol-util/id-factory
'
;
import
{
idFactory
}
from
'
mol-util/id-factory
'
;
...
@@ -24,9 +22,6 @@ export interface Renderable<T extends RenderableValues> {
...
@@ -24,9 +22,6 @@ export interface Renderable<T extends RenderableValues> {
readonly
id
:
number
readonly
id
:
number
readonly
values
:
T
readonly
values
:
T
readonly
state
:
RenderableState
readonly
state
:
RenderableState
readonly
boundingSphere
:
Sphere3D
readonly
invariantBoundingSphere
:
Sphere3D
readonly
z
:
number
render
:
(
variant
:
RenderVariant
)
=>
void
render
:
(
variant
:
RenderVariant
)
=>
void
getProgram
:
(
variant
:
RenderVariant
)
=>
Program
getProgram
:
(
variant
:
RenderVariant
)
=>
Program
...
@@ -35,28 +30,10 @@ export interface Renderable<T extends RenderableValues> {
...
@@ -35,28 +30,10 @@ export interface Renderable<T extends RenderableValues> {
}
}
export
function
createRenderable
<
T
extends
Values
<
RenderableSchema
>>
(
renderItem
:
RenderItem
,
values
:
T
,
state
:
RenderableState
):
Renderable
<
T
>
{
export
function
createRenderable
<
T
extends
Values
<
RenderableSchema
>>
(
renderItem
:
RenderItem
,
values
:
T
,
state
:
RenderableState
):
Renderable
<
T
>
{
const
boundingSphere
:
Sphere3D
=
Sphere3D
.
create
(
Vec3
.
zero
(),
0
)
const
invariantBoundingSphere
:
Sphere3D
=
Sphere3D
.
create
(
Vec3
.
zero
(),
0
)
return
{
return
{
id
:
getNextRenderableId
(),
id
:
getNextRenderableId
(),
values
,
values
,
state
,
state
,
get
boundingSphere
()
{
if
(
values
.
boundingSphere
)
{
Sphere3D
.
copy
(
boundingSphere
,
values
.
boundingSphere
.
ref
.
value
)
}
return
boundingSphere
},
get
invariantBoundingSphere
()
{
if
(
values
.
invariantBoundingSphere
)
{
Sphere3D
.
copy
(
invariantBoundingSphere
,
values
.
invariantBoundingSphere
.
ref
.
value
)
}
return
invariantBoundingSphere
},
get
z
()
{
return
boundingSphere
.
center
[
2
]
},
render
:
(
variant
:
RenderVariant
)
=>
{
render
:
(
variant
:
RenderVariant
)
=>
{
if
(
values
.
uPickable
)
{
if
(
values
.
uPickable
)
{
...
...
This diff is collapsed.
Click to expand it.
src/mol-gl/scene.ts
+
13
−
11
View file @
9ae27784
...
@@ -18,15 +18,15 @@ function calculateBoundingSphere(renderables: Renderable<RenderableValues & Base
...
@@ -18,15 +18,15 @@ function calculateBoundingSphere(renderables: Renderable<RenderableValues & Base
boundaryHelper
.
reset
(
0.1
);
boundaryHelper
.
reset
(
0.1
);
for
(
let
i
=
0
,
il
=
renderables
.
length
;
i
<
il
;
++
i
)
{
for
(
let
i
=
0
,
il
=
renderables
.
length
;
i
<
il
;
++
i
)
{
const
r
=
renderables
[
i
]
const
boundingSphere
=
renderables
[
i
]
.
values
.
boundingSphere
.
ref
.
value
if
(
!
r
.
boundingSphere
.
radius
)
continue
;
if
(
!
boundingSphere
.
radius
)
continue
;
boundaryHelper
.
boundaryStep
(
r
.
boundingSphere
.
center
,
r
.
boundingSphere
.
radius
);
boundaryHelper
.
boundaryStep
(
boundingSphere
.
center
,
boundingSphere
.
radius
);
}
}
boundaryHelper
.
finishBoundaryStep
();
boundaryHelper
.
finishBoundaryStep
();
for
(
let
i
=
0
,
il
=
renderables
.
length
;
i
<
il
;
++
i
)
{
for
(
let
i
=
0
,
il
=
renderables
.
length
;
i
<
il
;
++
i
)
{
const
r
=
renderables
[
i
]
const
boundingSphere
=
renderables
[
i
]
.
values
.
boundingSphere
.
ref
.
value
if
(
!
r
.
boundingSphere
.
radius
)
continue
;
if
(
!
boundingSphere
.
radius
)
continue
;
boundaryHelper
.
extendStep
(
r
.
boundingSphere
.
center
,
r
.
boundingSphere
.
radius
);
boundaryHelper
.
extendStep
(
boundingSphere
.
center
,
boundingSphere
.
radius
);
}
}
Vec3
.
copy
(
boundingSphere
.
center
,
boundaryHelper
.
center
);
Vec3
.
copy
(
boundingSphere
.
center
,
boundaryHelper
.
center
);
...
@@ -35,16 +35,18 @@ function calculateBoundingSphere(renderables: Renderable<RenderableValues & Base
...
@@ -35,16 +35,18 @@ function calculateBoundingSphere(renderables: Renderable<RenderableValues & Base
return
boundingSphere
;
return
boundingSphere
;
}
}
function
renderableSort
(
a
:
Renderable
<
any
>
,
b
:
Renderable
<
any
>
)
{
function
renderableSort
(
a
:
Renderable
<
RenderableValues
&
BaseValues
>
,
b
:
Renderable
<
RenderableValues
&
BaseValues
>
)
{
const
drawProgramIdA
=
a
.
getProgram
(
'
draw
'
).
id
const
drawProgramIdA
=
a
.
getProgram
(
'
draw
'
).
id
const
drawProgramIdB
=
b
.
getProgram
(
'
draw
'
).
id
const
drawProgramIdB
=
b
.
getProgram
(
'
draw
'
).
id
const
zA
=
a
.
values
.
boundingSphere
.
ref
.
value
.
center
[
2
]
const
zB
=
a
.
values
.
boundingSphere
.
ref
.
value
.
center
[
2
]
if
(
drawProgramIdA
!==
drawProgramIdB
)
{
if
(
drawProgramIdA
!==
drawProgramIdB
)
{
return
drawProgramIdA
-
drawProgramIdB
;
// sort by program id to minimize gl state changes
return
drawProgramIdA
-
drawProgramIdB
;
// sort by program id to minimize gl state changes
}
else
if
(
a
.
z
!==
b
.
z
)
{
}
else
if
(
z
A
!==
z
B
)
{
return
a
.
state
.
opaque
return
a
.
state
.
opaque
?
a
.
z
-
b
.
z
// when opaque draw closer elements first to minimize overdraw
?
zA
-
zB
// when opaque draw closer elements first to minimize overdraw
:
b
.
z
-
a
.
z
// when transparent draw elements last to maximize partial visibility
:
zB
-
zA
// when transparent draw elements last to maximize partial visibility
}
else
{
}
else
{
return
a
.
id
-
b
.
id
;
return
a
.
id
-
b
.
id
;
}
}
...
@@ -60,7 +62,7 @@ interface Scene extends Object3D {
...
@@ -60,7 +62,7 @@ interface Scene extends Object3D {
remove
:
(
o
:
RenderObject
)
=>
void
remove
:
(
o
:
RenderObject
)
=>
void
has
:
(
o
:
RenderObject
)
=>
boolean
has
:
(
o
:
RenderObject
)
=>
boolean
clear
:
()
=>
void
clear
:
()
=>
void
forEach
:
(
callbackFn
:
(
value
:
Renderable
<
any
>
,
key
:
RenderObject
)
=>
void
)
=>
void
forEach
:
(
callbackFn
:
(
value
:
Renderable
<
RenderableValues
&
BaseValues
>
,
key
:
RenderObject
)
=>
void
)
=>
void
}
}
namespace
Scene
{
namespace
Scene
{
...
...
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