@expofp/renderer 3.50.0 → 3.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Renderer.d.ts +2 -2
- package/dist/core/batch/BatchedMesh.d.ts +12 -0
- package/dist/core/batch/BatchedMesh.js +29 -0
- package/dist/core/instanced/InstancedMesh.js +7 -2
- package/dist/core/sprites/BatchedSprites.js +2 -2
- package/dist/core/sprites/RaycastingSprites.d.ts +9 -1
- package/dist/core/sprites/RaycastingSprites.js +23 -3
- package/dist/core/sprites/sprite-material.js +5 -6
- package/dist/core/text/MemberTexture.js +2 -4
- package/dist/events/LayoutDriver.js +17 -1
- package/dist/events/layout-targets.js +30 -5
- package/dist/events/placement/box.d.ts +14 -0
- package/dist/events/placement/box.js +19 -2
- package/dist/events/placement/index.d.ts +1 -0
- package/dist/events/placement/index.js +1 -0
- package/dist/events/placement/pass.js +9 -8
- package/dist/events/pointer.d.ts +27 -6
- package/dist/events/pointer.js +50 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/objects/images/Images.js +1 -1
- package/dist/objects/lighting/Lighting.d.ts +56 -38
- package/dist/objects/lighting/Lighting.js +130 -343
- package/dist/objects/lighting/lighting-gui.js +32 -18
- package/dist/objects/lighting/studio-environment.d.ts +15 -43
- package/dist/objects/lighting/studio-environment.js +18 -126
- package/dist/objects/lighting/sun-shadow-map.d.ts +24 -19
- package/dist/objects/lighting/sun-shadow-map.js +112 -34
- package/dist/objects/materials/ColorMaterial.d.ts +11 -8
- package/dist/objects/materials/ColorMaterial.js +33 -11
- package/dist/objects/materials/ModelMaterial.js +3 -2
- package/dist/objects/materials/OutlineMaterial.d.ts +21 -0
- package/dist/objects/materials/OutlineMaterial.js +77 -0
- package/dist/objects/materials/TextureMaterial.d.ts +10 -0
- package/dist/objects/materials/TextureMaterial.js +13 -2
- package/dist/objects/materials/effects/ao/index.d.ts +2 -5
- package/dist/objects/materials/effects/ao/index.js +4 -7
- package/dist/objects/materials/effects/contact-shadow.d.ts +21 -10
- package/dist/objects/materials/effects/contact-shadow.js +60 -16
- package/dist/objects/materials/effects/effects-context.d.ts +2 -1
- package/dist/objects/materials/effects/effects-context.js +2 -1
- package/dist/objects/materials/effects/side-shade.d.ts +40 -0
- package/dist/objects/materials/effects/side-shade.js +52 -0
- package/dist/objects/materials/effects/sun-shadow.d.ts +5 -21
- package/dist/objects/materials/effects/sun-shadow.js +54 -103
- package/dist/objects/models/Models.d.ts +3 -2
- package/dist/objects/models/Models.js +7 -6
- package/dist/objects/models/model-asset.d.ts +51 -21
- package/dist/objects/models/model-asset.js +100 -40
- package/dist/objects/models/model-container.d.ts +37 -13
- package/dist/objects/models/model-container.js +74 -22
- package/dist/objects/shapes/Shapes.js +11 -6
- package/dist/objects/shapes/shape-container.d.ts +3 -2
- package/dist/objects/shapes/shape-container.js +6 -4
- package/dist/objects/shapes/shape-geometry.d.ts +16 -4
- package/dist/objects/shapes/shape-geometry.js +17 -13
- package/dist/types/defs.d.ts +30 -1
- package/dist/utils/math.d.ts +14 -0
- package/dist/utils/math.js +20 -0
- package/package.json +2 -2
|
@@ -10,13 +10,14 @@ import { SlotContainer } from '../containers';
|
|
|
10
10
|
* Solids draw after the flat shapes, so a volume occludes the flat content of its own layer rather
|
|
11
11
|
* than being painted over by it — the same rule that governs whole layers, applied within one.
|
|
12
12
|
*/
|
|
13
|
-
export declare const SHAPE_KINDS: readonly ['planar', 'solid', 'translucent'];
|
|
13
|
+
export declare const SHAPE_KINDS: readonly ['planar', 'solid', 'translucent', 'outline'];
|
|
14
14
|
/**
|
|
15
|
-
* Which of a layer's
|
|
15
|
+
* Which of a layer's shape batches a def belongs in, and what that batch is for:
|
|
16
16
|
*
|
|
17
17
|
* - `planar` — flat content: unlit, no depth writes, placed by draw order alone.
|
|
18
18
|
* - `solid` — opaque volumes: lit and depth-writing, drawn in the ordered stream.
|
|
19
19
|
* - `translucent` — the same volumes, drawn in three's transparent pass.
|
|
20
|
+
* - `outline` — volumes drawn as their silhouette alone, see {@link ShapeDef.outline}.
|
|
20
21
|
*
|
|
21
22
|
* One value rather than the `solid`/`translucent` pair it replaces. The pair could express a
|
|
22
23
|
* translucent-but-flat batch, which nothing partitions for and no material describes, and it split
|
|
@@ -9,7 +9,7 @@ import { shapeGeometry } from './shape-geometry';
|
|
|
9
9
|
* Solids draw after the flat shapes, so a volume occludes the flat content of its own layer rather
|
|
10
10
|
* than being painted over by it — the same rule that governs whole layers, applied within one.
|
|
11
11
|
*/
|
|
12
|
-
export const SHAPE_KINDS = ['planar', 'solid', 'translucent'];
|
|
12
|
+
export const SHAPE_KINDS = ['planar', 'solid', 'translucent', 'outline'];
|
|
13
13
|
/**
|
|
14
14
|
* The batch a def belongs in.
|
|
15
15
|
*
|
|
@@ -44,6 +44,8 @@ export const SHAPE_KINDS = ['planar', 'solid', 'translucent'];
|
|
|
44
44
|
export function shapeKindOf(def) {
|
|
45
45
|
if (!isMesh(def.shape) || def.shape.isPlanar)
|
|
46
46
|
return 'planar';
|
|
47
|
+
if (def.outline)
|
|
48
|
+
return 'outline';
|
|
47
49
|
return isTranslucentColor(def.color) ? 'translucent' : 'solid';
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
@@ -119,9 +121,9 @@ export class ShapeContainer extends SlotContainer {
|
|
|
119
121
|
* @returns The geometry, built on first use.
|
|
120
122
|
*/
|
|
121
123
|
geometryFor(shape) {
|
|
122
|
-
// Both volume kinds share one layout, which is what lets the cache serve a def crossing
|
|
123
|
-
// them without rebuilding anything.
|
|
124
|
-
return shapeGeometry(shape, this.kind
|
|
124
|
+
// Both filled volume kinds share one layout, which is what lets the cache serve a def crossing
|
|
125
|
+
// between them without rebuilding anything.
|
|
126
|
+
return shapeGeometry(shape, this.kind === 'translucent' ? 'solid' : this.kind);
|
|
125
127
|
}
|
|
126
128
|
/**
|
|
127
129
|
* Declares the membership this container is about to hold, setting the size the next growth jumps
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type Shape } from '@expofp/geometry';
|
|
2
2
|
import { BufferGeometry } from 'three';
|
|
3
|
+
/** The layouts a shape's template geometry comes in, one per kind of container that draws it. */
|
|
4
|
+
export type ShapeLayout = keyof ShapeLayouts;
|
|
3
5
|
/**
|
|
4
6
|
* The template geometry a shape draws with, in the layout its batch locks itself into. Boxes and
|
|
5
7
|
* rects share one unit plane and are placed by their instance transform; meshes and polygons carry
|
|
@@ -17,11 +19,21 @@ import { BufferGeometry } from 'three';
|
|
|
17
19
|
* ones until their shape is collected, the two planes for the life of the process, which is a few
|
|
18
20
|
* hundred bytes of vertex data against a plane rebuilt per shape layer of every plan.
|
|
19
21
|
* @param shape - The shape to resolve.
|
|
20
|
-
* @param
|
|
22
|
+
* @param layout - The layout of the container drawing it. A batched mesh mirrors its first
|
|
21
23
|
* geometry's attributes *and* its index-ness and three rejects any later geometry that disagrees,
|
|
22
|
-
* so the container's own
|
|
23
|
-
*
|
|
24
|
+
* so the container's own layout decides rather than anything derived here — a container holding
|
|
25
|
+
* a shape it should not is then caught by `addGeometry` rather than served quietly.
|
|
24
26
|
* @returns The geometry, built on first use.
|
|
25
27
|
*/
|
|
26
|
-
export declare function shapeGeometry(shape: Shape,
|
|
28
|
+
export declare function shapeGeometry(shape: Shape, layout: ShapeLayout): BufferGeometry;
|
|
29
|
+
/** The layouts one shape has been built in, each filled on first use. */
|
|
30
|
+
interface ShapeLayouts {
|
|
31
|
+
/** Indexed and position-only, for the unlit material a flat batch draws with. */
|
|
32
|
+
planar?: BufferGeometry;
|
|
33
|
+
/** Non-indexed with creased normals, for the lit material a volume batch draws with. */
|
|
34
|
+
solid?: BufferGeometry;
|
|
35
|
+
/** Non-indexed with smooth normals, for the material an outline batch draws with. */
|
|
36
|
+
outline?: BufferGeometry;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
27
39
|
//# sourceMappingURL=shape-geometry.d.ts.map
|
|
@@ -18,22 +18,22 @@ import { toCreasedNormals } from 'three/examples/jsm/utils/BufferGeometryUtils.j
|
|
|
18
18
|
* ones until their shape is collected, the two planes for the life of the process, which is a few
|
|
19
19
|
* hundred bytes of vertex data against a plane rebuilt per shape layer of every plan.
|
|
20
20
|
* @param shape - The shape to resolve.
|
|
21
|
-
* @param
|
|
21
|
+
* @param layout - The layout of the container drawing it. A batched mesh mirrors its first
|
|
22
22
|
* geometry's attributes *and* its index-ness and three rejects any later geometry that disagrees,
|
|
23
|
-
* so the container's own
|
|
24
|
-
*
|
|
23
|
+
* so the container's own layout decides rather than anything derived here — a container holding
|
|
24
|
+
* a shape it should not is then caught by `addGeometry` rather than served quietly.
|
|
25
25
|
* @returns The geometry, built on first use.
|
|
26
26
|
*/
|
|
27
|
-
export function shapeGeometry(shape,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
export function shapeGeometry(shape, layout) {
|
|
28
|
+
if (isBox(shape) || isRect(shape)) {
|
|
29
|
+
return (planes[layout] ??= makePlaneGeometry(layout !== 'planar'));
|
|
30
|
+
}
|
|
31
31
|
let layouts = shapeGeometries.get(shape);
|
|
32
32
|
if (!layouts) {
|
|
33
33
|
layouts = {};
|
|
34
34
|
shapeGeometries.set(shape, layouts);
|
|
35
35
|
}
|
|
36
|
-
return (layouts[layout] ??= makeMeshGeometry(shape,
|
|
36
|
+
return (layouts[layout] ??= makeMeshGeometry(shape, layout));
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* The unit plane every box and rect draws with, scaled and placed by its instance transform.
|
|
@@ -52,25 +52,29 @@ function makePlaneGeometry(solid) {
|
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Builds geometry from a mesh-like shape: indexed and position-only for a planar container,
|
|
55
|
-
* non-indexed with creased normals for a solid one
|
|
55
|
+
* non-indexed with creased normals for a solid one, and non-indexed with smooth normals for an
|
|
56
|
+
* outline.
|
|
56
57
|
*
|
|
57
58
|
* The creasing is what makes an extruded shape read as architecture rather than as a smoothed blob —
|
|
58
59
|
* faces meeting at more than 30° keep a hard edge, so walls stay flat and corners stay sharp.
|
|
60
|
+
*
|
|
61
|
+
* An outline pushes each vertex out along its normal, so it wants every corner's normal shared by
|
|
62
|
+
* the faces meeting there: a hard edge would push its two faces apart and open a notch at it.
|
|
59
63
|
* @param mesh - The shape supplying vertices and triangle indices.
|
|
60
|
-
* @param
|
|
64
|
+
* @param layout - The container's layout.
|
|
61
65
|
* @returns The geometry.
|
|
62
66
|
*/
|
|
63
|
-
function makeMeshGeometry(mesh,
|
|
67
|
+
function makeMeshGeometry(mesh, layout) {
|
|
64
68
|
const geometry = new BufferGeometry()
|
|
65
69
|
.setFromPoints(mesh.vertices)
|
|
66
70
|
.setIndex(mesh.indices.flat());
|
|
67
|
-
if (
|
|
71
|
+
if (layout === 'planar')
|
|
68
72
|
return geometry;
|
|
69
73
|
// Not chained: `computeVertexNormals` returns void rather than `this`, and `toCreasedNormals`
|
|
70
74
|
// needs the seed normals it writes.
|
|
71
75
|
const expanded = geometry.toNonIndexed();
|
|
72
76
|
expanded.computeVertexNormals();
|
|
73
|
-
return toCreasedNormals(expanded, CREASE_ANGLE);
|
|
77
|
+
return toCreasedNormals(expanded, layout === 'solid' ? CREASE_ANGLE : Math.PI);
|
|
74
78
|
}
|
|
75
79
|
/**
|
|
76
80
|
* Template geometry per mesh-like shape, weak so it is collected with the shape that keyed it.
|
package/dist/types/defs.d.ts
CHANGED
|
@@ -67,8 +67,12 @@ export interface ClusterOptions {
|
|
|
67
67
|
* The size of the marker you draw for a cluster. Any def or cluster that this marker would
|
|
68
68
|
* cover joins the cluster. Without it, the marker takes the size of the cluster's first member.
|
|
69
69
|
* When several clustering layers share a scope, the first layer's marker is used.
|
|
70
|
+
*
|
|
71
|
+
* A function sizes each cluster's marker from what it holds, for a marker that grows with its
|
|
72
|
+
* count or changes shape with its members. The pass calls it each time it measures a cluster,
|
|
73
|
+
* which is again after every def the cluster absorbs, so keep it cheap.
|
|
70
74
|
*/
|
|
71
|
-
marker?: ClusterMarker;
|
|
75
|
+
marker?: ClusterMarker | ((members: readonly (ImageDef | TextDef)[], unitCount: number) => ClusterMarker);
|
|
72
76
|
/**
|
|
73
77
|
* Receives the full current set of clusters whenever it changes. A layer that loses all its
|
|
74
78
|
* clusters receives an empty array once.
|
|
@@ -104,6 +108,11 @@ export interface Cluster {
|
|
|
104
108
|
readonly y: number;
|
|
105
109
|
/** The greatest elevation of its members, in plan units. */
|
|
106
110
|
readonly elevation: number;
|
|
111
|
+
/**
|
|
112
|
+
* The defs that stand behind the cluster, seed first. A fresh array on each report, so a caller
|
|
113
|
+
* may keep it.
|
|
114
|
+
*/
|
|
115
|
+
readonly members: readonly (ImageDef | TextDef)[];
|
|
107
116
|
}
|
|
108
117
|
/**
|
|
109
118
|
* How a def competes for room on screen.
|
|
@@ -136,6 +145,20 @@ export interface PlacementOptions {
|
|
|
136
145
|
group?: string;
|
|
137
146
|
/** CSS pixels added around the tested box: one value, or `[horizontal, vertical]`. */
|
|
138
147
|
padding?: number | [number, number];
|
|
148
|
+
/**
|
|
149
|
+
* The rect the pass tests, apart from the one the def is drawn at: in the units of the def's own
|
|
150
|
+
* `bounds`, its center standing on {@link origin}. Its center is also the def's anchor in a
|
|
151
|
+
* cluster. Without it, the pass tests `bounds`.
|
|
152
|
+
*
|
|
153
|
+
* With it, `bounds` and the def's own `origin` are drawing alone, so an animation can write them
|
|
154
|
+
* every frame: an `update()` that changes only them owes no pass and moves no cluster.
|
|
155
|
+
*/
|
|
156
|
+
bounds?: Rect;
|
|
157
|
+
/**
|
|
158
|
+
* The point of {@link bounds} that its center names, as in {@link ImageDef.origin}. Defaults to
|
|
159
|
+
* the def's own origin.
|
|
160
|
+
*/
|
|
161
|
+
origin?: [number, number];
|
|
139
162
|
/** How the def competes. Defaults to `never`. */
|
|
140
163
|
overlap?: OverlapMode;
|
|
141
164
|
}
|
|
@@ -162,6 +185,12 @@ export interface ShapeDef extends SharedDef {
|
|
|
162
185
|
shape: Shape;
|
|
163
186
|
/** The shape's color. */
|
|
164
187
|
color: ColorInput;
|
|
188
|
+
/**
|
|
189
|
+
* Draws a solid shape as its outline alone: a line a few screen pixels wide around its silhouette,
|
|
190
|
+
* in {@link color}, hidden wherever nearer content covers it. A flat shape has no silhouette and
|
|
191
|
+
* ignores this.
|
|
192
|
+
*/
|
|
193
|
+
outline?: boolean;
|
|
165
194
|
}
|
|
166
195
|
/** Image definition. */
|
|
167
196
|
export interface ImageDef extends ScreenSpaceDef {
|
package/dist/utils/math.d.ts
CHANGED
|
@@ -49,4 +49,18 @@ export declare function axisLength(matrix: Matrix4, axis: number): number;
|
|
|
49
49
|
* @returns The distance in world units, or `0` for a camera that never meets the plane ahead of it.
|
|
50
50
|
*/
|
|
51
51
|
export declare function aimDepth(camera: Camera, planToWorld: Matrix4): number;
|
|
52
|
+
/**
|
|
53
|
+
* The depth a screen-space def's plan-unit size is exact at: {@link aimDepth} under a projection
|
|
54
|
+
* that divides by depth, and `0`, which turns the depth correction off, under one that does not.
|
|
55
|
+
*
|
|
56
|
+
* Read off the projection matrix rather than the camera's `isPerspectiveCamera` brand or an exact
|
|
57
|
+
* `-1` in its w row. An external host hands its camera a projection with its own unit conversion
|
|
58
|
+
* folded in (MapLibre's w row reads about `-1e8`), on a plain `Camera`, and that projection divides
|
|
59
|
+
* by depth all the same. A perspective w row takes view z and drops the constant term; an
|
|
60
|
+
* orthographic one is the constant `1` alone.
|
|
61
|
+
* @param camera - The camera this draw uses.
|
|
62
|
+
* @param planToWorld - The batch's world matrix.
|
|
63
|
+
* @returns The depth in world units, or `0` for no correction.
|
|
64
|
+
*/
|
|
65
|
+
export declare function referenceDepth(camera: Camera, planToWorld: Matrix4): number;
|
|
52
66
|
//# sourceMappingURL=math.d.ts.map
|
package/dist/utils/math.js
CHANGED
|
@@ -69,6 +69,26 @@ export function aimDepth(camera, planToWorld) {
|
|
|
69
69
|
// Behind the camera is no measurement, so the shader keeps its plan-unit sizing instead.
|
|
70
70
|
return depth > 0 ? depth : 0;
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* The depth a screen-space def's plan-unit size is exact at: {@link aimDepth} under a projection
|
|
74
|
+
* that divides by depth, and `0`, which turns the depth correction off, under one that does not.
|
|
75
|
+
*
|
|
76
|
+
* Read off the projection matrix rather than the camera's `isPerspectiveCamera` brand or an exact
|
|
77
|
+
* `-1` in its w row. An external host hands its camera a projection with its own unit conversion
|
|
78
|
+
* folded in (MapLibre's w row reads about `-1e8`), on a plain `Camera`, and that projection divides
|
|
79
|
+
* by depth all the same. A perspective w row takes view z and drops the constant term; an
|
|
80
|
+
* orthographic one is the constant `1` alone.
|
|
81
|
+
* @param camera - The camera this draw uses.
|
|
82
|
+
* @param planToWorld - The batch's world matrix.
|
|
83
|
+
* @returns The depth in world units, or `0` for no correction.
|
|
84
|
+
*/
|
|
85
|
+
export function referenceDepth(camera, planToWorld) {
|
|
86
|
+
const elements = camera.projectionMatrix.elements;
|
|
87
|
+
// Column-major: element 11 is w's view-z coefficient, element 15 its constant term.
|
|
88
|
+
if (!(Math.abs(elements[11]) > Math.abs(elements[15])))
|
|
89
|
+
return 0;
|
|
90
|
+
return aimDepth(camera, planToWorld);
|
|
91
|
+
}
|
|
72
92
|
// Scratch for aimDepth, filled and consumed within one call.
|
|
73
93
|
const _direction = new Vector3();
|
|
74
94
|
const _normal = new Vector3();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expofp/renderer",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.52.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/expofp/efp-app.git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"troika-three-text": "^0.52.5",
|
|
43
43
|
"tslib": "^2.3.0",
|
|
44
44
|
"webgl-memory": "^1.1.3",
|
|
45
|
-
"@expofp/geometry": "3.
|
|
45
|
+
"@expofp/geometry": "3.52.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@react-three/test-renderer": "^9.1.0",
|