|
@@ -37,12 +37,12 @@ export type StructureGroup = { structure: Structure, group: Unit.SymmetryGroup }
|
|
|
|
|
|
export interface UnitsVisual<P extends RepresentationProps = {}> extends Visual<StructureGroup, P> { }
|
|
|
|
|
|
-function createUnitsRenderObject<G extends Geometry>(group: Unit.SymmetryGroup, geometry: G, locationIt: LocationIterator, theme: Theme, props: PD.Values<Geometry.Params<G>>) {
|
|
|
+function createUnitsRenderObject<G extends Geometry>(group: Unit.SymmetryGroup, geometry: G, locationIt: LocationIterator, theme: Theme, props: PD.Values<Geometry.Params<G>>, materialId: number) {
|
|
|
const { createValues, createRenderableState } = Geometry.getUtils(geometry)
|
|
|
const transform = createUnitsTransform(group)
|
|
|
const values = createValues(geometry, transform, locationIt, theme, props)
|
|
|
const state = createRenderableState(props)
|
|
|
- return createRenderObject(geometry.kind, values, state)
|
|
|
+ return createRenderObject(geometry.kind, values, state, materialId)
|
|
|
}
|
|
|
|
|
|
interface UnitsVisualBuilder<P extends UnitsParams, G extends Geometry> {
|
|
@@ -58,7 +58,7 @@ interface UnitsVisualGeometryBuilder<P extends UnitsParams, G extends Geometry>
|
|
|
geometryUtils: GeometryUtils<G>
|
|
|
}
|
|
|
|
|
|
-export function UnitsVisual<G extends Geometry, P extends UnitsParams & Geometry.Params<G>>(builder: UnitsVisualGeometryBuilder<P, G>): UnitsVisual<P> {
|
|
|
+export function UnitsVisual<G extends Geometry, P extends UnitsParams & Geometry.Params<G>>(builder: UnitsVisualGeometryBuilder<P, G>, materialId: number): UnitsVisual<P> {
|
|
|
const { defaultProps, createGeometry, createLocationIterator, getLoci, eachLocation, setUpdateState } = builder
|
|
|
const { createEmpty: createEmptyGeometry, updateValues, updateBoundingSphere, updateRenderableState } = builder.geometryUtils
|
|
|
const updateState = VisualUpdateState.create()
|
|
@@ -140,7 +140,7 @@ export function UnitsVisual<G extends Geometry, P extends UnitsParams & Geometry
|
|
|
if (updateState.createNew) {
|
|
|
locationIt = createLocationIterator(newStructureGroup.group)
|
|
|
if (newGeometry) {
|
|
|
- renderObject = createUnitsRenderObject(newStructureGroup.group, newGeometry, locationIt, newTheme, newProps)
|
|
|
+ renderObject = createUnitsRenderObject(newStructureGroup.group, newGeometry, locationIt, newTheme, newProps, materialId)
|
|
|
} else {
|
|
|
throw new Error('expected geometry to be given')
|
|
|
}
|
|
@@ -258,7 +258,7 @@ export const UnitsMeshParams = { ...StructureMeshParams, ...UnitsParams }
|
|
|
export type UnitsMeshParams = typeof UnitsMeshParams
|
|
|
export interface UnitsMeshVisualBuilder<P extends UnitsMeshParams> extends UnitsVisualBuilder<P, Mesh> { }
|
|
|
|
|
|
-export function UnitsMeshVisual<P extends UnitsMeshParams>(builder: UnitsMeshVisualBuilder<P>): UnitsVisual<P> {
|
|
|
+export function UnitsMeshVisual<P extends UnitsMeshParams>(builder: UnitsMeshVisualBuilder<P>, materialId: number): UnitsVisual<P> {
|
|
|
return UnitsVisual<Mesh, StructureMeshParams & UnitsParams>({
|
|
|
...builder,
|
|
|
setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme) => {
|
|
@@ -266,7 +266,7 @@ export function UnitsMeshVisual<P extends UnitsMeshParams>(builder: UnitsMeshVis
|
|
|
if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.createGeometry = true
|
|
|
},
|
|
|
geometryUtils: Mesh.Utils
|
|
|
- })
|
|
|
+ }, materialId)
|
|
|
}
|
|
|
|
|
|
// spheres
|
|
@@ -275,7 +275,7 @@ export const UnitsSpheresParams = { ...StructureSpheresParams, ...UnitsParams }
|
|
|
export type UnitsSpheresParams = typeof UnitsSpheresParams
|
|
|
export interface UnitsSpheresVisualBuilder<P extends UnitsSpheresParams> extends UnitsVisualBuilder<P, Spheres> { }
|
|
|
|
|
|
-export function UnitsSpheresVisual<P extends UnitsSpheresParams>(builder: UnitsSpheresVisualBuilder<P>): UnitsVisual<P> {
|
|
|
+export function UnitsSpheresVisual<P extends UnitsSpheresParams>(builder: UnitsSpheresVisualBuilder<P>, materialId: number): UnitsVisual<P> {
|
|
|
return UnitsVisual<Spheres, StructureSpheresParams & UnitsParams>({
|
|
|
...builder,
|
|
|
setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme) => {
|
|
@@ -283,7 +283,7 @@ export function UnitsSpheresVisual<P extends UnitsSpheresParams>(builder: UnitsS
|
|
|
if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.updateSize = true
|
|
|
},
|
|
|
geometryUtils: Spheres.Utils
|
|
|
- })
|
|
|
+ }, materialId)
|
|
|
}
|
|
|
|
|
|
// points
|
|
@@ -292,7 +292,7 @@ export const UnitsPointsParams = { ...StructurePointsParams, ...UnitsParams }
|
|
|
export type UnitsPointsParams = typeof UnitsPointsParams
|
|
|
export interface UnitsPointVisualBuilder<P extends UnitsPointsParams> extends UnitsVisualBuilder<P, Points> { }
|
|
|
|
|
|
-export function UnitsPointsVisual<P extends UnitsPointsParams>(builder: UnitsPointVisualBuilder<P>): UnitsVisual<P> {
|
|
|
+export function UnitsPointsVisual<P extends UnitsPointsParams>(builder: UnitsPointVisualBuilder<P>, materialId: number): UnitsVisual<P> {
|
|
|
return UnitsVisual<Points, StructurePointsParams & UnitsParams>({
|
|
|
...builder,
|
|
|
setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme) => {
|
|
@@ -300,7 +300,7 @@ export function UnitsPointsVisual<P extends UnitsPointsParams>(builder: UnitsPoi
|
|
|
if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.updateSize = true
|
|
|
},
|
|
|
geometryUtils: Points.Utils
|
|
|
- })
|
|
|
+ }, materialId)
|
|
|
}
|
|
|
|
|
|
// lines
|
|
@@ -309,7 +309,7 @@ export const UnitsLinesParams = { ...StructureLinesParams, ...UnitsParams }
|
|
|
export type UnitsLinesParams = typeof UnitsLinesParams
|
|
|
export interface UnitsLinesVisualBuilder<P extends UnitsLinesParams> extends UnitsVisualBuilder<P, Lines> { }
|
|
|
|
|
|
-export function UnitsLinesVisual<P extends UnitsLinesParams>(builder: UnitsLinesVisualBuilder<P>): UnitsVisual<P> {
|
|
|
+export function UnitsLinesVisual<P extends UnitsLinesParams>(builder: UnitsLinesVisualBuilder<P>, materialId: number): UnitsVisual<P> {
|
|
|
return UnitsVisual<Lines, StructureLinesParams & UnitsParams>({
|
|
|
...builder,
|
|
|
setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme) => {
|
|
@@ -317,7 +317,7 @@ export function UnitsLinesVisual<P extends UnitsLinesParams>(builder: UnitsLines
|
|
|
if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.updateSize = true
|
|
|
},
|
|
|
geometryUtils: Lines.Utils
|
|
|
- })
|
|
|
+ }, materialId)
|
|
|
}
|
|
|
|
|
|
// direct-volume
|
|
@@ -326,7 +326,7 @@ export const UnitsDirectVolumeParams = { ...StructureDirectVolumeParams, ...Unit
|
|
|
export type UnitsDirectVolumeParams = typeof UnitsDirectVolumeParams
|
|
|
export interface UnitsDirectVolumeVisualBuilder<P extends UnitsDirectVolumeParams> extends UnitsVisualGeometryBuilder<P, DirectVolume> { }
|
|
|
|
|
|
-export function UnitsDirectVolumeVisual<P extends UnitsDirectVolumeParams>(builder: UnitsDirectVolumeVisualBuilder<P>): UnitsVisual<P> {
|
|
|
+export function UnitsDirectVolumeVisual<P extends UnitsDirectVolumeParams>(builder: UnitsDirectVolumeVisualBuilder<P>, materialId: number): UnitsVisual<P> {
|
|
|
return UnitsVisual<DirectVolume, StructureDirectVolumeParams & UnitsParams>({
|
|
|
...builder,
|
|
|
setUpdateState: (state: VisualUpdateState, newProps: PD.Values<P>, currentProps: PD.Values<P>, newTheme: Theme, currentTheme: Theme) => {
|
|
@@ -334,5 +334,5 @@ export function UnitsDirectVolumeVisual<P extends UnitsDirectVolumeParams>(build
|
|
|
if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.createGeometry = true
|
|
|
},
|
|
|
geometryUtils: DirectVolume.Utils
|
|
|
- })
|
|
|
+ }, materialId)
|
|
|
}
|