@synchronized-console/viewer 2.25.71 → 2.31.14
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/IViewer.d.ts +8 -2
- package/dist/index.d.ts +10 -6
- package/dist/index.js +4 -4
- package/dist/modules/EventEmitter.d.ts +5 -4
- package/dist/modules/LegacyViewer.d.ts +1 -1
- package/dist/modules/SynchronizedRenderer.d.ts +9 -1
- package/dist/modules/Viewer.d.ts +2 -1
- package/dist/modules/batching/Batch.d.ts +7 -0
- package/dist/modules/batching/BatchObject.d.ts +2 -1
- package/dist/modules/batching/Batcher.d.ts +3 -0
- package/dist/modules/batching/LineBatch.d.ts +7 -3
- package/dist/modules/batching/MeshBatch.d.ts +1 -1
- package/dist/modules/batching/PointBatch.d.ts +1 -1
- package/dist/modules/batching/TextBatch.d.ts +27 -8
- package/dist/modules/batching/TextBatchObject.d.ts +9 -0
- package/dist/modules/converter/Geometry.d.ts +18 -6
- package/dist/modules/converter/MeshTriangulationHelper.d.ts +2 -41
- package/dist/modules/converter/VirtualArray.d.ts +30 -0
- package/dist/modules/extensions/ExplodeExtension.d.ts +4 -0
- package/dist/modules/extensions/controls/FlyControls.d.ts +6 -3
- package/dist/modules/extensions/measurements/AreaMeasurement.d.ts +8 -2
- package/dist/modules/extensions/measurements/Measurement.d.ts +6 -0
- package/dist/modules/extensions/measurements/MeasurementPointGizmo.d.ts +8 -6
- package/dist/modules/extensions/measurements/MeasurementsExtension.d.ts +22 -16
- package/dist/modules/extensions/measurements/PerpendicularMeasurement.d.ts +4 -1
- package/dist/modules/extensions/measurements/PointMeasurement.d.ts +6 -4
- package/dist/modules/extensions/measurements/PointToPointMeasurement.d.ts +2 -0
- package/dist/modules/extensions/sections/SectionTool.d.ts +49 -2
- package/dist/modules/input/Input.d.ts +6 -2
- package/dist/modules/loaders/Synchronized/SynchronizedConverter.d.ts +7 -1
- package/dist/modules/loaders/Synchronized/SynchronizedGeometryConverter.d.ts +7 -3
- package/dist/modules/loaders/Synchronized/SynchronizedLoader.d.ts +5 -3
- package/dist/modules/materials/Materials.d.ts +1 -0
- package/dist/modules/materials/SynchronizedBasicMaterial.d.ts +8 -7
- package/dist/modules/materials/SynchronizedTextColoredMaterial.d.ts +8 -0
- package/dist/modules/materials/SynchronizedTextMaterial.d.ts +9 -17
- package/dist/modules/materials/shaders/synchronized-basic-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-depth-normal-id-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-depth-normal-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-displace.vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-ghost-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-normal-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-standard-colored-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-standard-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-text-frag.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-text-vert.d.ts +1 -1
- package/dist/modules/materials/shaders/synchronized-viewport-vert.d.ts +1 -1
- package/dist/modules/objects/AccelerationStructure.d.ts +1 -1
- package/dist/modules/objects/SynchronizedBatchedText.d.ts +59 -0
- package/dist/modules/objects/TextLabel.d.ts +51 -0
- package/dist/modules/pipeline/Passes/GPass.d.ts +9 -3
- package/dist/modules/pipeline/Pipelines/EdgesPipeline.d.ts +2 -0
- package/dist/modules/tree/NodeMap.d.ts +9 -0
- package/dist/modules/tree/NodeRenderView.d.ts +13 -5
- package/dist/modules/tree/RenderTree.d.ts +5 -1
- package/dist/modules/tree/WorldTree.d.ts +6 -0
- package/package.json +9 -6
- package/dist/modules/objects/SynchronizedText.d.ts +0 -39
|
@@ -5,32 +5,27 @@ import { Measurement } from './Measurement.js';
|
|
|
5
5
|
import { ExtendedMeshIntersection } from '../../objects/SynchronizedRaycaster.js';
|
|
6
6
|
import { Extension } from '../Extension.js';
|
|
7
7
|
import { CameraController } from '../CameraController.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
POINT = 3
|
|
8
|
+
import { MeasurementData, MeasurementOptions } from '@synchronized-console/shared/viewer/state';
|
|
9
|
+
export declare enum MeasurementEvent {
|
|
10
|
+
CountChanged = "measurement-count-changed",
|
|
11
|
+
MeasurementsChanged = "measurements-changed"
|
|
13
12
|
}
|
|
14
|
-
export interface
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
vertexSnap?: boolean;
|
|
18
|
-
units?: string;
|
|
19
|
-
precision?: number;
|
|
20
|
-
chain?: boolean;
|
|
13
|
+
export interface MeasurementEventPayload {
|
|
14
|
+
[MeasurementEvent.CountChanged]: number;
|
|
15
|
+
[MeasurementEvent.MeasurementsChanged]: Measurement[];
|
|
21
16
|
}
|
|
22
17
|
export declare class MeasurementsExtension extends Extension {
|
|
23
18
|
protected cameraProvider: CameraController;
|
|
24
19
|
get inject(): (typeof CameraController)[];
|
|
25
20
|
protected renderer: SynchronizedRenderer;
|
|
26
|
-
protected
|
|
21
|
+
protected _measurements: Measurement[];
|
|
27
22
|
protected _activeMeasurement: Measurement | null;
|
|
28
23
|
protected _selectedMeasurement: Measurement | null;
|
|
29
|
-
protected raycaster: Raycaster;
|
|
30
24
|
protected _options: MeasurementOptions;
|
|
31
25
|
private _frameLock;
|
|
32
26
|
private _paused;
|
|
33
27
|
private _sceneHit;
|
|
28
|
+
protected raycaster: Raycaster;
|
|
34
29
|
private pointBuff;
|
|
35
30
|
private normalBuff;
|
|
36
31
|
private screenBuff0;
|
|
@@ -41,7 +36,11 @@ export declare class MeasurementsExtension extends Extension {
|
|
|
41
36
|
set options(options: MeasurementOptions);
|
|
42
37
|
get selectedMeasurement(): Measurement | null;
|
|
43
38
|
get activeMeasurement(): Measurement | null;
|
|
39
|
+
get measurementCount(): number;
|
|
40
|
+
get mesurements(): Measurement[];
|
|
41
|
+
private emitMeasurementCountChanged;
|
|
44
42
|
constructor(viewer: IViewer, cameraProvider: CameraController);
|
|
43
|
+
on<T extends MeasurementEvent>(eventType: T, listener: (arg: MeasurementEventPayload[T]) => void): void;
|
|
45
44
|
onLateUpdate(): void;
|
|
46
45
|
onResize(): void;
|
|
47
46
|
protected onPointerMove(data: Vector2 & {
|
|
@@ -59,7 +58,13 @@ export declare class MeasurementsExtension extends Extension {
|
|
|
59
58
|
protected startMeasurement(): Measurement;
|
|
60
59
|
protected cancelMeasurement(): void;
|
|
61
60
|
protected finishMeasurement(): void;
|
|
62
|
-
|
|
61
|
+
protected pushMeasurement(measurement: Measurement): void;
|
|
62
|
+
protected findMeasurementFromData(measurementData: MeasurementData): Measurement | undefined;
|
|
63
|
+
removeMeasurement(measurementData?: MeasurementData): void;
|
|
64
|
+
/**
|
|
65
|
+
* Idempotent way of setting measurements
|
|
66
|
+
*/
|
|
67
|
+
setMeasurements(measurements: MeasurementData[]): void;
|
|
63
68
|
clearMeasurements(): void;
|
|
64
69
|
protected flashMeasurement(): void;
|
|
65
70
|
protected pickMeasurement(data: Vector2): Measurement | null;
|
|
@@ -67,5 +72,6 @@ export declare class MeasurementsExtension extends Extension {
|
|
|
67
72
|
protected snap(intersection: ExtendedMeshIntersection, outPoint: Vector3, outNormal: Vector3): void;
|
|
68
73
|
protected updateClippingPlanes(planes: Plane[]): void;
|
|
69
74
|
protected applyOptions(): void;
|
|
70
|
-
|
|
75
|
+
addMeasurement(measurementData: MeasurementData): void;
|
|
76
|
+
toMeasurementData(): MeasurementData[];
|
|
71
77
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Box3, Camera, Plane, Raycaster, Vector2, Vector3, type Intersection } from 'three';
|
|
2
2
|
import { Measurement } from './Measurement.js';
|
|
3
|
+
import { MeasurementData, MeasurementType } from '@synchronized-console/shared/viewer/state';
|
|
3
4
|
export declare class PerpendicularMeasurement extends Measurement {
|
|
4
5
|
private startGizmo;
|
|
5
6
|
private endGizmo;
|
|
6
|
-
private normalIndicatorPixelSize;
|
|
7
7
|
flipStartNormal: boolean;
|
|
8
8
|
midPoint: Vector3;
|
|
9
9
|
set isVisible(value: boolean);
|
|
10
10
|
get bounds(): Box3;
|
|
11
|
+
get measurementType(): MeasurementType;
|
|
11
12
|
constructor();
|
|
12
13
|
frameUpdate(camera: Camera, size: Vector2, bounds: Box3): void;
|
|
13
14
|
locationUpdated(point: Vector3, normal: Vector3): void;
|
|
@@ -16,4 +17,6 @@ export declare class PerpendicularMeasurement extends Measurement {
|
|
|
16
17
|
raycast(raycaster: Raycaster, intersects: Array<Intersection>): void;
|
|
17
18
|
highlight(value: boolean): void;
|
|
18
19
|
updateClippingPlanes(planes: Plane[]): void;
|
|
20
|
+
toMeasurementData(): MeasurementData;
|
|
21
|
+
fromMeasurementData(data: MeasurementData): void;
|
|
19
22
|
}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { Box3, Camera, Plane, Raycaster, Vector2, Vector3, type Intersection } from 'three';
|
|
2
2
|
import { Measurement } from './Measurement.js';
|
|
3
|
-
import {
|
|
3
|
+
import { TextLabel } from '../../objects/TextLabel.js';
|
|
4
4
|
import { MeasurementPointGizmo } from './MeasurementPointGizmo.js';
|
|
5
|
+
import { MeasurementType } from '@synchronized-console/shared/viewer/state';
|
|
5
6
|
export declare class PointMeasurement extends Measurement {
|
|
6
7
|
protected gizmo: MeasurementPointGizmo;
|
|
7
|
-
protected xLabel:
|
|
8
|
-
protected yLabel:
|
|
9
|
-
protected zLabel:
|
|
8
|
+
protected xLabel: TextLabel;
|
|
9
|
+
protected yLabel: TextLabel;
|
|
10
|
+
protected zLabel: TextLabel;
|
|
10
11
|
protected xLabelPosition: Vector3;
|
|
11
12
|
protected yLabelPosition: Vector3;
|
|
12
13
|
protected zLabelPosition: Vector3;
|
|
13
14
|
protected readonly pixelsOffX: number;
|
|
14
15
|
protected readonly pixelsOffY: number;
|
|
15
16
|
set isVisible(value: boolean);
|
|
17
|
+
get measurementType(): MeasurementType;
|
|
16
18
|
constructor();
|
|
17
19
|
frameUpdate(camera: Camera, size: Vector2, bounds: Box3): void;
|
|
18
20
|
locationUpdated(point: Vector3, normal: Vector3): void;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Box3, Camera, Plane, Raycaster, Vector2, Vector3, type Intersection } from 'three';
|
|
2
2
|
import { Measurement } from './Measurement.js';
|
|
3
|
+
import { MeasurementType } from '@synchronized-console/shared/viewer/state';
|
|
3
4
|
export declare class PointToPointMeasurement extends Measurement {
|
|
4
5
|
private startGizmo;
|
|
5
6
|
private endGizmo;
|
|
6
7
|
set isVisible(value: boolean);
|
|
8
|
+
get measurementType(): MeasurementType;
|
|
7
9
|
constructor();
|
|
8
10
|
frameUpdate(camera: Camera, size: Vector2, bounds: Box3): void;
|
|
9
11
|
locationUpdated(point: Vector3, normal: Vector3): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Group, Box3, BufferGeometry, Mesh, Vector3, Plane, Raycaster, Object3D, Matrix4, Vector2, Face, PlaneGeometry } from 'three';
|
|
1
|
+
import { Group, Box3, BufferGeometry, Mesh, Vector3, Plane, Raycaster, Quaternion, Object3D, Matrix4, Vector2, Face, PlaneGeometry } from 'three';
|
|
2
2
|
import { TransformControls } from '../TransformControls.js';
|
|
3
3
|
import { OBB } from 'three/examples/jsm/math/OBB.js';
|
|
4
4
|
import { type IViewer } from '../../../IViewer.js';
|
|
@@ -20,6 +20,12 @@ export interface SectionToolEventPayload {
|
|
|
20
20
|
export declare class SectionTool extends Extension {
|
|
21
21
|
protected cameraProvider: CameraController;
|
|
22
22
|
get inject(): (typeof CameraController)[];
|
|
23
|
+
/** Configurable rotation snap angle in radians. Set to null to disable snapping */
|
|
24
|
+
rotationSnapAngle: number | null;
|
|
25
|
+
/** Note: Rotation snapping only applies to mouse interactions via TransformControls.
|
|
26
|
+
* Programmatic calls to setBox() will not apply rotation snapping.
|
|
27
|
+
* For complete snapping support, programmatic rotations will need to be handled separately.
|
|
28
|
+
*/
|
|
23
29
|
/** This is our data model. All we need is an OBB */
|
|
24
30
|
protected obb: OBB;
|
|
25
31
|
/** The planes that will send out as clipping planes */
|
|
@@ -111,6 +117,12 @@ export declare class SectionTool extends Extension {
|
|
|
111
117
|
/** Hit testing related */
|
|
112
118
|
protected raycaster: Raycaster;
|
|
113
119
|
protected dragging: boolean;
|
|
120
|
+
protected shiftKeyPressed: boolean;
|
|
121
|
+
protected keydownHandler: (e: KeyboardEvent) => void;
|
|
122
|
+
protected keyupHandler: (e: KeyboardEvent) => void;
|
|
123
|
+
protected sectionBoxHistory: OBB[];
|
|
124
|
+
protected currentHistoryIndex: number;
|
|
125
|
+
protected maxHistorySize: number;
|
|
114
126
|
/** Manadatory property for all extensions */
|
|
115
127
|
get enabled(): boolean;
|
|
116
128
|
set enabled(value: boolean);
|
|
@@ -155,12 +167,28 @@ export declare class SectionTool extends Extension {
|
|
|
155
167
|
* Creates the controls and all their gizmos
|
|
156
168
|
*/
|
|
157
169
|
protected setupControls(): void;
|
|
170
|
+
/**
|
|
171
|
+
* Creates an OBB state from the current OBB
|
|
172
|
+
*/
|
|
173
|
+
protected createObbState(): OBB;
|
|
174
|
+
/**
|
|
175
|
+
* Applies an OBB state to the current OBB
|
|
176
|
+
*/
|
|
177
|
+
protected applyObbState(state: OBB): void;
|
|
178
|
+
/**
|
|
179
|
+
* Saves the current section box state to history
|
|
180
|
+
*/
|
|
181
|
+
protected saveToHistory(): void;
|
|
182
|
+
/**
|
|
183
|
+
* Sets up keyboard event listeners for shift key rotation snapping and undo/redo
|
|
184
|
+
*/
|
|
185
|
+
protected setupKeyboardListeners(): void;
|
|
158
186
|
/**
|
|
159
187
|
* Controls, outline and hitbox update based on the OBB model
|
|
160
188
|
*/
|
|
161
189
|
protected updateVisual(): void;
|
|
162
190
|
/**
|
|
163
|
-
* Triggers when
|
|
191
|
+
* Triggers when transform interactions start/stop
|
|
164
192
|
* @param event Controls event
|
|
165
193
|
*/
|
|
166
194
|
protected draggingHandler(event: any): void;
|
|
@@ -216,4 +244,23 @@ export declare class SectionTool extends Extension {
|
|
|
216
244
|
min: Vector3Like;
|
|
217
245
|
max: Vector3Like;
|
|
218
246
|
} | OBB): box is OBB;
|
|
247
|
+
/**
|
|
248
|
+
* Snaps a quaternion to the nearest grid based on rotationSnapAngle.
|
|
249
|
+
* This is useful for rotation snapping.
|
|
250
|
+
* @param q The quaternion to snap.
|
|
251
|
+
* @returns The snapped quaternion.
|
|
252
|
+
*/
|
|
253
|
+
protected snapQuaternionToGrid(q: Quaternion): Quaternion;
|
|
254
|
+
/**
|
|
255
|
+
* Undoes the last section box change
|
|
256
|
+
*/
|
|
257
|
+
protected undoSectionBox(): void;
|
|
258
|
+
/**
|
|
259
|
+
* Redoes the last undone section box change
|
|
260
|
+
*/
|
|
261
|
+
protected redoSectionBox(): void;
|
|
262
|
+
/**
|
|
263
|
+
* Cleanup method to remove event listeners and prevent memory leaks
|
|
264
|
+
*/
|
|
265
|
+
dispose(): void;
|
|
219
266
|
}
|
|
@@ -8,7 +8,9 @@ export declare enum InputEvent {
|
|
|
8
8
|
Wheel = "wheel",
|
|
9
9
|
Click = "click",
|
|
10
10
|
DoubleClick = "double-click",
|
|
11
|
-
KeyUp = "key-up"
|
|
11
|
+
KeyUp = "key-up",
|
|
12
|
+
KeyDown = "key-down",
|
|
13
|
+
ContextMenu = "context-menu"
|
|
12
14
|
}
|
|
13
15
|
export interface InputEventPayload {
|
|
14
16
|
[InputEvent.PointerDown]: Vector2 & {
|
|
@@ -31,6 +33,8 @@ export interface InputEventPayload {
|
|
|
31
33
|
multiSelect: boolean;
|
|
32
34
|
};
|
|
33
35
|
[InputEvent.KeyUp]: KeyboardEvent;
|
|
36
|
+
[InputEvent.KeyDown]: KeyboardEvent;
|
|
37
|
+
[InputEvent.ContextMenu]: PointerEvent;
|
|
34
38
|
}
|
|
35
39
|
export default class Input extends EventEmitter {
|
|
36
40
|
private static readonly MAX_DOUBLE_CLICK_TIMING;
|
|
@@ -40,7 +44,7 @@ export default class Input extends EventEmitter {
|
|
|
40
44
|
private lastClick;
|
|
41
45
|
private touchLocation;
|
|
42
46
|
private container;
|
|
43
|
-
constructor(container: HTMLElement);
|
|
47
|
+
constructor(container: HTMLElement, restrictKeyInput?: boolean);
|
|
44
48
|
on<T extends InputEvent>(eventType: T, listener: (arg: InputEventPayload[T]) => void): void;
|
|
45
49
|
_getNormalisedClickPosition(e: MouseEvent | Touch): Vector2;
|
|
46
50
|
dispose(): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type TreeNode, WorldTree } from '../../tree/WorldTree.js';
|
|
2
2
|
import { type SynchronizedObject } from '../../../index.js';
|
|
3
3
|
import { ObjectLoader2 } from '@synchronized-console/objectloader2';
|
|
4
|
-
export type ConverterResultDelegate = () =>
|
|
4
|
+
export type ConverterResultDelegate = (count: number) => void;
|
|
5
5
|
export type SynchronizedConverterNodeDelegate = ((object: SynchronizedObject, node: TreeNode) => Promise<void>) | null;
|
|
6
6
|
/**
|
|
7
7
|
* Utility class providing some top level conversion methods.
|
|
@@ -33,6 +33,8 @@ export default class SynchronizedConverter {
|
|
|
33
33
|
[id: string]: SynchronizedObject;
|
|
34
34
|
};
|
|
35
35
|
protected instanceCounter: number;
|
|
36
|
+
protected duplicateCounter: number;
|
|
37
|
+
private traverseCount;
|
|
36
38
|
protected readonly NodeConverterMapping: {
|
|
37
39
|
[name: string]: SynchronizedConverterNodeDelegate;
|
|
38
40
|
};
|
|
@@ -47,6 +49,7 @@ export default class SynchronizedConverter {
|
|
|
47
49
|
*/
|
|
48
50
|
traverse(objectURL: string, obj: SynchronizedObject, callback: ConverterResultDelegate, node?: TreeNode | null): Promise<void>;
|
|
49
51
|
private getNodeId;
|
|
52
|
+
private addNode;
|
|
50
53
|
/**
|
|
51
54
|
* Takes an array composed of chunked references and dechunks it.
|
|
52
55
|
* @param {[type]} arr [description]
|
|
@@ -74,6 +77,7 @@ export default class SynchronizedConverter {
|
|
|
74
77
|
private getBlockDefinitionGeometry;
|
|
75
78
|
/** We're wasting a few milis here, but it is what it is */
|
|
76
79
|
private getCompoundId;
|
|
80
|
+
private getDuplicateId;
|
|
77
81
|
private getEmptyTransformData;
|
|
78
82
|
/**
|
|
79
83
|
*
|
|
@@ -115,4 +119,6 @@ export default class SynchronizedConverter {
|
|
|
115
119
|
private CircleToNode;
|
|
116
120
|
private ArcToNode;
|
|
117
121
|
private EllipseToNode;
|
|
122
|
+
/** We shouldn't need to work with duplicates */
|
|
123
|
+
handleDuplicates(): Promise<void>;
|
|
118
124
|
}
|
|
@@ -2,6 +2,8 @@ import { type GeometryData } from '../../converter/Geometry.js';
|
|
|
2
2
|
import { type NodeData } from '../../tree/WorldTree.js';
|
|
3
3
|
import { Vector2, Vector3 } from 'three';
|
|
4
4
|
import { GeometryConverter, SynchronizedType } from '../GeometryConverter.js';
|
|
5
|
+
import { DataChunk } from '../../../IViewer.js';
|
|
6
|
+
import { ChunkArray } from '../../converter/VirtualArray.js';
|
|
5
7
|
export declare class SynchronizedGeometryConverter extends GeometryConverter {
|
|
6
8
|
typeLookupTable: {
|
|
7
9
|
[type: string]: SynchronizedType;
|
|
@@ -104,7 +106,7 @@ export declare class SynchronizedGeometryConverter extends GeometryConverter {
|
|
|
104
106
|
y: number;
|
|
105
107
|
z: number;
|
|
106
108
|
};
|
|
107
|
-
}, radius: number, startAngle?: number, endAngle?: number,
|
|
109
|
+
}, radius: number, startAngle?: number, endAngle?: number, resolution?: number): Float64Array<ArrayBuffer>;
|
|
108
110
|
protected PointToVector3(obj: {
|
|
109
111
|
value: Array<number>;
|
|
110
112
|
units: string;
|
|
@@ -112,7 +114,7 @@ export declare class SynchronizedGeometryConverter extends GeometryConverter {
|
|
|
112
114
|
x: number;
|
|
113
115
|
y: number;
|
|
114
116
|
z: number;
|
|
115
|
-
}, scale?: boolean): Vector3;
|
|
117
|
+
}, target?: Vector3, scale?: boolean): Vector3;
|
|
116
118
|
protected PointToFloatArray(obj: {
|
|
117
119
|
value: Array<number>;
|
|
118
120
|
units: string;
|
|
@@ -122,6 +124,8 @@ export declare class SynchronizedGeometryConverter extends GeometryConverter {
|
|
|
122
124
|
z: number;
|
|
123
125
|
}): number[];
|
|
124
126
|
protected FlattenVector3Array(input: Vector3[] | Vector2[]): number[];
|
|
125
|
-
protected unpackColors(int32Colors:
|
|
127
|
+
protected unpackColors(int32Colors: ChunkArray, tolinear?: boolean): number[];
|
|
126
128
|
protected srgbToLinear(x: number): number;
|
|
129
|
+
/** Connectors send empty chunks ಠ_ಠ */
|
|
130
|
+
protected chunkArrayHasData(chunks: Array<DataChunk>): boolean;
|
|
127
131
|
}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import SynchronizedConverter from './SynchronizedConverter.js';
|
|
2
2
|
import { Loader } from '../Loader.js';
|
|
3
3
|
import { WorldTree } from '../../../index.js';
|
|
4
|
-
import { ObjectLoader2 } from '@synchronized-console/objectloader2';
|
|
4
|
+
import { ObjectLoader2, ObjectAttributeMask } from '@synchronized-console/objectloader2';
|
|
5
5
|
export declare class SynchronizedLoader extends Loader {
|
|
6
6
|
protected loader: ObjectLoader2;
|
|
7
7
|
protected converter: SynchronizedConverter;
|
|
8
8
|
protected tree: WorldTree;
|
|
9
9
|
protected isCancelled: boolean;
|
|
10
10
|
protected isFinished: boolean;
|
|
11
|
+
protected log: (message?: string, ...args: unknown[]) => void;
|
|
11
12
|
get resource(): string;
|
|
12
13
|
get finished(): boolean;
|
|
13
|
-
constructor(targetTree: WorldTree, resource: string, authToken?: string, enableCaching?: boolean, resourceData?: unknown);
|
|
14
|
-
protected initObjectLoader(resource: string, authToken?: string, _enableCaching?: boolean, resourceData?: unknown): ObjectLoader2;
|
|
14
|
+
constructor(targetTree: WorldTree, resource: string, authToken?: string, enableCaching?: boolean, resourceData?: unknown, logger?: (message?: string, ...args: unknown[]) => void, attributeMask?: ObjectAttributeMask, objectTypeMask?: string[]);
|
|
15
|
+
protected initObjectLoader(resource: string, authToken?: string, _enableCaching?: boolean, resourceData?: unknown, attributeMask?: ObjectAttributeMask, objectTypeMask?: string[]): ObjectLoader2;
|
|
15
16
|
load(): Promise<boolean>;
|
|
17
|
+
private progressListen;
|
|
16
18
|
cancel(): void;
|
|
17
19
|
dispose(): void;
|
|
18
20
|
}
|
|
@@ -57,6 +57,7 @@ export default class Materials {
|
|
|
57
57
|
private pointCloudGradientMaterial;
|
|
58
58
|
private textGhostMaterial;
|
|
59
59
|
private textColoredMaterial;
|
|
60
|
+
private textGradientMaterial;
|
|
60
61
|
private textHiddenMaterial;
|
|
61
62
|
private defaultGradientTextureData;
|
|
62
63
|
private static readonly NullRenderMaterialHash;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { Material, type IUniform, Vector2, type MeshBasicMaterialParameters, Scene, Camera, BufferGeometry, Object3D } from 'three';
|
|
2
|
-
import { Matrix4 } from 'three';
|
|
3
2
|
import { ExtendedMeshBasicMaterial, type Uniforms } from './SynchronizedMaterial.js';
|
|
4
3
|
import type { SynchronizedWebGLRenderer } from '../objects/SynchronizedWebGLRenderer.js';
|
|
4
|
+
export type BillboardingType = 'world' | 'screen';
|
|
5
5
|
declare class SynchronizedBasicMaterial extends ExtendedMeshBasicMaterial {
|
|
6
|
-
protected
|
|
7
|
-
protected
|
|
8
|
-
private _billboardPixelHeight;
|
|
9
|
-
private _billboardOffset;
|
|
6
|
+
protected _billboardPixelSize: Vector2;
|
|
7
|
+
protected _billboardPixelOffset: Vector2;
|
|
10
8
|
protected get vertexProgram(): string;
|
|
11
9
|
protected get fragmentProgram(): string;
|
|
12
10
|
protected get baseUniforms(): {
|
|
13
11
|
[uniform: string]: IUniform;
|
|
14
12
|
};
|
|
15
13
|
protected get uniformsDef(): Uniforms;
|
|
16
|
-
|
|
17
|
-
set
|
|
14
|
+
get billboardPixelSize(): Vector2;
|
|
15
|
+
set billboardPixelSize(value: Vector2);
|
|
16
|
+
get billboardPixeOffset(): Vector2;
|
|
17
|
+
set billboardPixelOffset(value: Vector2);
|
|
18
18
|
constructor(parameters: MeshBasicMaterialParameters, defines?: string[]);
|
|
19
19
|
/** We need a unique key per program */
|
|
20
20
|
customProgramCacheKey(): string;
|
|
21
21
|
copy(source: Material): this;
|
|
22
22
|
fastCopy(from: Material, to: Material): void;
|
|
23
|
+
setBillboarding(type: BillboardingType | null): void;
|
|
23
24
|
/** Called by three.js render loop */
|
|
24
25
|
onBeforeRender(_this: SynchronizedWebGLRenderer, _scene: Scene, camera: Camera, _geometry: BufferGeometry, object: Object3D): void;
|
|
25
26
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import SynchronizedTextMaterial from './SynchronizedTextMaterial.js';
|
|
2
|
+
declare class SynchronizedTextColoredMaterial extends SynchronizedTextMaterial {
|
|
3
|
+
gradientIndexMap: {
|
|
4
|
+
[index: number]: number;
|
|
5
|
+
};
|
|
6
|
+
updateGradientIndexMap(index: number, value: number): void;
|
|
7
|
+
}
|
|
8
|
+
export default SynchronizedTextColoredMaterial;
|
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
protected static readonly matBuff: Matrix4;
|
|
7
|
-
protected static readonly vecBuff: Vector2;
|
|
8
|
-
private _billboardPixelHeight;
|
|
1
|
+
import { Material, Texture } from 'three';
|
|
2
|
+
import { type Uniforms } from './SynchronizedMaterial.js';
|
|
3
|
+
import SynchronizedBasicMaterial from './SynchronizedBasicMaterial.js';
|
|
4
|
+
declare class SynchronizedTextMaterial extends SynchronizedBasicMaterial {
|
|
5
|
+
setMatrixTexture: (texture: Texture) => void;
|
|
9
6
|
protected get vertexProgram(): string;
|
|
10
7
|
protected get fragmentProgram(): string;
|
|
11
|
-
protected get baseUniforms(): {
|
|
12
|
-
[uniform: string]: IUniform;
|
|
13
|
-
};
|
|
14
8
|
protected get uniformsDef(): Uniforms;
|
|
15
|
-
set billboardPixelHeight(value: number);
|
|
16
|
-
get billboardPixelHeight(): number;
|
|
17
|
-
constructor(parameters: MeshBasicMaterialParameters, defines?: Array<string>);
|
|
18
9
|
/** We need a unique key per program */
|
|
19
10
|
customProgramCacheKey(): string;
|
|
20
|
-
|
|
11
|
+
protected copyCustomUniforms(material: Material): void;
|
|
21
12
|
getDerivedMaterial(): any;
|
|
13
|
+
/** Sadly, troika does not export this for no good reason so we neee to copy it over */
|
|
14
|
+
getDerivedBatchedMaterial(): any;
|
|
22
15
|
fastCopy(from: Material, to: Material): void;
|
|
23
|
-
|
|
24
|
-
onBeforeRender(_this: SynchronizedWebGLRenderer, _scene: Scene, camera: Camera, _geometry: BufferGeometry, _object: Object3D): void;
|
|
16
|
+
setGradientTexture(texture: Texture): void;
|
|
25
17
|
}
|
|
26
18
|
export default SynchronizedTextMaterial;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const synchronizedBasicVert = "\n#include <common>\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n attribute float objIndex;\n\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n } \n#endif\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n\n#endif\n\n#if defined(BILLBOARD) || defined(BILLBOARD_FIXED)\n uniform vec3 billboardPos;\n uniform mat4 invProjection;\n#endif\n#ifdef BILLBOARD_FIXED\n uniform vec2 billboardSize;\n uniform vec2 billboardOffset;\n#endif\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t// #include <project_vertex> COMMENTED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n \n mvPosition = modelViewMatrix * mvPosition;\n \n #if defined(BILLBOARD)\n float div = 1.;\n gl_Position = projectionMatrix * (viewMatrix * vec4(billboardPos, 1.0) + vec4(position.x, position.y, 0., 0.0));\n #elif defined(BILLBOARD_FIXED)\n gl_Position = projectionMatrix * (viewMatrix * vec4(billboardPos, 1.0));\n float div = gl_Position.w;\n gl_Position /= gl_Position.w;\n gl_Position.xy += (position.xy + billboardOffset) * billboardSize;\n #else\n gl_Position = projectionMatrix * mvPosition;\n #endif\n\n\n\t#include <logdepthbuf_vertex>\n\t// #include <clipping_planes_vertex> COMMENTED CHUNK\n #if NUM_CLIPPING_PLANES > 0\n #if defined(BILLBOARD) || defined(BILLBOARD_FIXED)\n vec4 movelViewProjection = gl_Position * div;\n vClipPosition = - (invProjection * movelViewProjection).xyz;\n #else\n\t vClipPosition = - mvPosition.xyz;\n #endif\n #endif\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}\n";
|
|
1
|
+
export declare const synchronizedBasicVert = "\n#include <common>\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n attribute float objIndex;\n\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n } \n#endif\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n\n#endif\n\n#if defined(BILLBOARD) || defined(BILLBOARD_SCREEN)\n uniform mat4 invProjection;\n#endif\n\n#ifdef BILLBOARD_SCREEN\n uniform vec4 billboardPixelOffsetSize;\n#endif\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n // #include <defaultnormal_vertex> // COMMENTED CHUNK\n vec3 transformedNormal = objectNormal;\n #ifdef USE_INSTANCING\n\n // this is in lieu of a per-instance normal-matrix\n // shear transforms in the instance matrix are not supported\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n \n /* If we have negative scaling, we flip the normal */\n float signDet = sign(dot(m[0], cross(m[1], m[2])));\n // Optional fallback: treat 0 as +1\n signDet = signDet + (1.0 - abs(signDet));\n transformedNormal *= signDet;\n #endif\n transformedNormal = normalMatrix * transformedNormal;\n #ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n #endif\n #ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n #endif\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t// #include <project_vertex> COMMENTED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n \n mvPosition = modelViewMatrix * mvPosition;\n \n #if defined(BILLBOARD)\n float div = 1.;\n gl_Position = projectionMatrix * (viewMatrix * vec4(modelMatrix[3].xyz, 1.0) + vec4(position.x, position.y, 0., 0.0));\n #elif defined(BILLBOARD_SCREEN)\n gl_Position = projectionMatrix * (viewMatrix * vec4(modelMatrix[3].xyz, 1.0));\n float div = gl_Position.w;\n gl_Position /= gl_Position.w;\n gl_Position.xy += position.xy * billboardPixelOffsetSize.zw * 2. + billboardPixelOffsetSize.xy * 2.;\n #else\n gl_Position = projectionMatrix * mvPosition;\n #endif\n\n\n\t#include <logdepthbuf_vertex>\n\t// #include <clipping_planes_vertex> COMMENTED CHUNK\n #if NUM_CLIPPING_PLANES > 0\n #if defined(BILLBOARD) || defined(BILLBOARD_SCREEN)\n vec4 movelViewProjection = gl_Position * div;\n vClipPosition = - (invProjection * movelViewProjection).xyz;\n #else\n\t vClipPosition = - mvPosition.xyz;\n #endif\n #endif\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const synchronizedDepthNormalIdVert = "\n#include <common>\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n uniform mat4 rteModelViewMatrix;\n#endif\n\n#if defined( TRANSFORM_STORAGE ) || ( defined( USE_INSTANCING ) && __VERSION__ == 100)\n attribute float objIndex;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\nvarying vec3 vIdColor;\nuniform int batchIndex;\n\n#ifdef LINEAR_DEPTH\n varying vec4 vViewPosition;\n#endif\nvarying vec3 vNormal;\n\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n#endif\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n }\n#endif\n\n\n/** Original glsl100 and glsl300 hash functions. Good outputs but maybe a bit slow? */\n/*\n#if __VERSION__ == 300\n vec3 hashColor(uint id) {\n // A simple integer hash function\n id = (id ^ 61u) ^ (id >> 16u);\n id = id * 9u;\n id = id ^ (id >> 4u);\n id = id * 0x27d4eb2du;\n id = id ^ (id >> 15u);\n\n return vec3(\n float((id >> 16u) & 0xFFu) / 255.0,\n float((id >> 8u) & 0xFFu) / 255.0,\n float(id & 0xFFu) / 255.0\n );\n }\n#elif __VERSION__ == 100\n vec3 hashColor(float id) {\n // Step 1: Simulate XOR by using mod and floating-point arithmetic\n id = mod(id + 61.0, 4294967296.0);\n id = mod(id - floor(id / 65536.0), 4294967296.0); // Approximate id ^ (id >> 16)\n // Step 2: Multiply by 9 (same as original)\n id = mod(id * 9.0, 4294967296.0);\n // Step 3: Simulate XOR with division/mod trick\n id = mod(id - floor(id / 16.0), 4294967296.0); // Approximate id ^ (id >> 4)\n // Step 4: Multiply by large prime\n id = mod(id * 666083407.0, 4294967296.0); // Approximate * 0x27d4eb2dU\n // Step 5: Simulate final XOR\n id = mod(id - floor(id / 32768.0), 4294967296.0); // Approximate id ^ (id >> 15)\n // Convert hash to RGB by extracting \"fake\" bit shifts\n return vec3(\n mod(floor(id / 65536.0), 256.0) / 255.0, // Simulates (id >> 16) & 0xFF\n mod(floor(id / 256.0), 256.0) / 255.0, // Simulates (id >> 8) & 0xFF\n mod(id, 256.0) / 255.0 // Simulates id & 0xFF\n );\n }\n#endif\n*/\n\n/** Simpler hash function works on both glsl versions */\nhighp vec3 hashColor(float id) {\n // Large prime multipliers\n highp float r = mod(id * 127.1, 256.0) / 255.0;\n highp float g = mod(id * 987.654, 256.0) / 255.0;\n highp float b = mod(id * 4321.123, 256.0) / 255.0;\n \n return vec3(r, g, b);\n}\n\nint szudzikHash(int x, int y) {\n return (x >= y) ? (x * x + x + y) : (y * y + x);\n}\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n #include <beginnormal_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n #include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t//#include <project_vertex> // EDITED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n \n #ifdef USE_RTE\n mvPosition = rteModelViewMatrix * mvPosition;\n #else\n mvPosition = modelViewMatrix * mvPosition;\n #endif\n \n #ifdef LINEAR_DEPTH\n vViewPosition = mvPosition;\n #endif \n\n vNormal = normalize( transformedNormal );\n \n #ifdef TRANSFORM_STORAGE\n vIdColor = hashColor(float(szudzikHash(int(objIndex), batchIndex)));\n #else\n #if defined( USE_INSTANCING ) \n #if __VERSION__ == 300\n vIdColor = hashColor(float(szudzikHash(int(gl_InstanceID), batchIndex)));\n #elif __VERSION__ == 100\n vIdColor = hashColor(float(szudzikHash(int(objIndex), batchIndex)));\n #endif\n #else\n vIdColor = vec3(0.);\n #endif\n #endif\n\n\n gl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t// #include <clipping_planes_vertex>\n #if NUM_CLIPPING_PLANES > 0\n\t vClipPosition = - mvPosition.xyz;\n #endif\n\tvHighPrecisionZW = gl_Position.zw;\n}\n";
|
|
1
|
+
export declare const synchronizedDepthNormalIdVert = "\n#include <common>\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n uniform mat4 rteModelViewMatrix;\n#endif\n\n#if defined( TRANSFORM_STORAGE ) || ( defined( USE_INSTANCING ) && __VERSION__ == 100)\n attribute float objIndex;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\nvarying vec3 vIdColor;\nuniform int batchIndex;\n\n#ifdef LINEAR_DEPTH\n varying vec4 vViewPosition;\n#endif\nvarying vec3 vNormal;\n\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n#endif\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n }\n#endif\n\n\n/** Original glsl100 and glsl300 hash functions. Good outputs but maybe a bit slow? */\n/*\n#if __VERSION__ == 300\n vec3 hashColor(uint id) {\n // A simple integer hash function\n id = (id ^ 61u) ^ (id >> 16u);\n id = id * 9u;\n id = id ^ (id >> 4u);\n id = id * 0x27d4eb2du;\n id = id ^ (id >> 15u);\n\n return vec3(\n float((id >> 16u) & 0xFFu) / 255.0,\n float((id >> 8u) & 0xFFu) / 255.0,\n float(id & 0xFFu) / 255.0\n );\n }\n#elif __VERSION__ == 100\n vec3 hashColor(float id) {\n // Step 1: Simulate XOR by using mod and floating-point arithmetic\n id = mod(id + 61.0, 4294967296.0);\n id = mod(id - floor(id / 65536.0), 4294967296.0); // Approximate id ^ (id >> 16)\n // Step 2: Multiply by 9 (same as original)\n id = mod(id * 9.0, 4294967296.0);\n // Step 3: Simulate XOR with division/mod trick\n id = mod(id - floor(id / 16.0), 4294967296.0); // Approximate id ^ (id >> 4)\n // Step 4: Multiply by large prime\n id = mod(id * 666083407.0, 4294967296.0); // Approximate * 0x27d4eb2dU\n // Step 5: Simulate final XOR\n id = mod(id - floor(id / 32768.0), 4294967296.0); // Approximate id ^ (id >> 15)\n // Convert hash to RGB by extracting \"fake\" bit shifts\n return vec3(\n mod(floor(id / 65536.0), 256.0) / 255.0, // Simulates (id >> 16) & 0xFF\n mod(floor(id / 256.0), 256.0) / 255.0, // Simulates (id >> 8) & 0xFF\n mod(id, 256.0) / 255.0 // Simulates id & 0xFF\n );\n }\n#endif\n*/\n\n/** Simpler hash function works on both glsl versions */\nhighp vec3 hashColor(float id) {\n // Large prime multipliers\n highp float r = mod(id * 127.1, 256.0) / 255.0;\n highp float g = mod(id * 987.654, 256.0) / 255.0;\n highp float b = mod(id * 4321.123, 256.0) / 255.0;\n \n return vec3(r, g, b);\n}\n\nint szudzikHash(int x, int y) {\n return (x >= y) ? (x * x + x + y) : (y * y + x);\n}\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n #include <beginnormal_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n // #include <defaultnormal_vertex> // COMMENTED CHUNK\n vec3 transformedNormal = objectNormal;\n #ifdef USE_INSTANCING\n\n // this is in lieu of a per-instance normal-matrix\n // shear transforms in the instance matrix are not supported\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n \n /* If we have negative scaling, we flip the normal */\n float signDet = sign(dot(m[0], cross(m[1], m[2])));\n // Optional fallback: treat 0 as +1\n signDet = signDet + (1.0 - abs(signDet));\n transformedNormal *= signDet;\n #endif\n transformedNormal = normalMatrix * transformedNormal;\n #ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n #endif\n #ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n #endif\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t//#include <project_vertex> // EDITED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n \n #ifdef USE_RTE\n mvPosition = rteModelViewMatrix * mvPosition;\n #else\n mvPosition = modelViewMatrix * mvPosition;\n #endif\n \n #ifdef LINEAR_DEPTH\n vViewPosition = mvPosition;\n #endif \n\n vNormal = normalize( transformedNormal );\n \n #ifdef TRANSFORM_STORAGE\n vIdColor = hashColor(float(szudzikHash(int(objIndex), batchIndex)));\n #else\n #if defined( USE_INSTANCING ) \n #if __VERSION__ == 300\n vIdColor = hashColor(float(szudzikHash(int(gl_InstanceID), batchIndex)));\n #elif __VERSION__ == 100\n vIdColor = hashColor(float(szudzikHash(int(objIndex), batchIndex)));\n #endif\n #else\n vIdColor = vec3(0.);\n #endif\n #endif\n\n\n gl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t// #include <clipping_planes_vertex>\n #if NUM_CLIPPING_PLANES > 0\n\t vClipPosition = - mvPosition.xyz;\n #endif\n\tvHighPrecisionZW = gl_Position.zw;\n}\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const synchronizedDepthNormalVert = "\n#include <common>\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n uniform mat4 rteModelViewMatrix;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n attribute float objIndex;\n\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\n#ifdef LINEAR_DEPTH\n varying vec4 vViewPosition;\n#endif\nvarying vec3 vNormal;\n\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n#endif\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n }\n#endif\n\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n #include <beginnormal_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n #include <defaultnormal_vertex
|
|
1
|
+
export declare const synchronizedDepthNormalVert = "\n#include <common>\n#ifdef USE_RTE\n // The high component is stored as the default 'position' attribute buffer\n attribute vec3 position_low;\n uniform vec3 uViewer_high;\n uniform vec3 uViewer_low;\n uniform mat4 rteModelViewMatrix;\n#endif\n\n#ifdef TRANSFORM_STORAGE\n attribute float objIndex;\n\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n #define TRANSFORM_STRIDE 4\n #else\n #define TRANSFORM_STRIDE 4.\n #endif\n uniform sampler2D tTransforms;\n uniform float objCount;\n #elif TRANSFORM_STORAGE == 1\n uniform mat4 uTransforms[OBJ_COUNT];\n #endif\n#endif\n\n#ifdef LINEAR_DEPTH\n varying vec4 vViewPosition;\n#endif\nvarying vec3 vNormal;\n\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\n\n#ifdef TRANSFORM_STORAGE\n void objectTransform(out vec4 quaternion, out vec4 pivotLow, out vec4 pivotHigh, out vec4 translation, out vec4 scale){\n #if TRANSFORM_STORAGE == 0\n #if __VERSION__ == 300\n ivec2 uv = ivec2(int(objIndex) * TRANSFORM_STRIDE, 0); \n vec4 v0 = texelFetch( tTransforms, uv, 0 );\n vec4 v1 = texelFetch( tTransforms, uv + ivec2(1, 0), 0);\n vec4 v2 = texelFetch( tTransforms, uv + ivec2(2, 0), 0);\n vec4 v3 = texelFetch( tTransforms, uv + ivec2(3, 0), 0);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #else\n float size = objCount * TRANSFORM_STRIDE;\n vec2 cUv = vec2(0.5/size, 0.5);\n vec2 dUv = vec2(1./size, 0.);\n \n vec2 uv = vec2((objIndex * TRANSFORM_STRIDE)/size + cUv.x, cUv.y);\n vec4 v0 = texture2D( tTransforms, uv);\n vec4 v1 = texture2D( tTransforms, uv + dUv);\n vec4 v2 = texture2D( tTransforms, uv + 2. * dUv);\n vec4 v3 = texture2D( tTransforms, uv + 3. * dUv);\n quaternion = v0;\n pivotLow = vec4(v1.xyz, 1.);\n pivotHigh = vec4(v2.xyz, 1.);\n translation = vec4(v3.xyz, 1.);\n scale = vec4(v1.w, v2.w, v3.w, 1.);\n #endif\n #elif TRANSFORM_STORAGE == 1\n mat4 tMatrix = uTransforms[int(objIndex)];\n quaternion = tMatrix[0];\n pivotLow = vec4(tMatrix[1].xyz, 1.);\n pivotHigh = vec4(tMatrix[2].xyz, 1.);\n translation = vec4(tMatrix[3].xyz, 1.);\n scale = vec4(tMatrix[1][3], tMatrix[2][3], tMatrix[3][3], 1.);\n #endif\n }\n\n vec3 rotate_vertex_position(vec3 position, vec4 quat)\n { \n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n }\n\n /** Another workaround for Apple's stupid compiler */\n vec4 safeMul(vec4 a, vec4 b) {\n // Prevents constant folding and optimization\n return (a + vec4(0.0)) * (b + vec4(1.0)) - a * vec4(1.0);\n }\n\n highp vec3 rotate_scaled_vertex_position_delta(highp vec4 v0, highp vec4 v1, highp vec4 scale, highp vec4 quat)\n {\n /** !!! WORKAROUND FOR Intel IrisXe CARDS !!! */\n /** The code below will not produce correct results in intel IrisXE integrated GPUs. \n * The geometry will turn mangled, albeit stable\n * I can't know for sure what is going on, but rotating the difference seems to \n * force the result into a lower precision?\n */\n // highp vec4 position = v0 - v1;\n // return position.xyz + 2.0 * cross(quat.xyz, cross(quat.xyz, position.xyz) + quat.w * position.xyz);\n\n /** Subtracting the rotated vectors works. */\n return rotate_vertex_position(safeMul(v0, scale).xyz, quat) - rotate_vertex_position(safeMul(v1, scale).xyz, quat) ;\n\n /** An alternate workaround is\n * highp vec3 position = (v0.xyz * (1. + 1e-7)) - (v1.xyz * (1. + 1e-7));\n return position + 2.0 * cross(quat.xyz, cross(quat.xyz, position) + quat.w * position);\n\n However I'm not such a fan of the (1. + 1e-7) part\n */\n }\n#endif\n\n#ifdef USE_RTE\n highp vec4 computeRelativePosition(in highp vec3 position_low, in highp vec3 position_high, in highp vec3 relativeTo_low, in highp vec3 relativeTo_high){\n /* \n Source https://github.com/virtualglobebook/OpenGlobe/blob/master/Source/Examples/Chapter05/Jitter/GPURelativeToEyeDSFUN90/Shaders/VS.glsl \n Note here, we're storing the high part of the position encoding inside three's default 'position' attribute buffer so we avoid redundancy \n */\n highp vec3 t1 = position_low.xyz - relativeTo_low.xyz;\n highp vec3 e = t1 - position_low.xyz;\n /** This is redunant, but necessary as a workaround for Apple platforms */\n highp float x = position_high.x - relativeTo_high.x;\n highp float y = position_high.y - relativeTo_high.y;\n highp float z = position_high.z - relativeTo_high.z;\n highp vec3 v = vec3(x, y, z);\n /** End of redundant part */\n highp vec3 t2 = ((-relativeTo_low - e) + (position_low.xyz - (t1 - e))) + v;\n highp vec3 highDifference = t1 + t2;\n highp vec3 lowDifference = t2 - (highDifference.xyz - t1.xyz);\n \n highp vec3 position = highDifference.xyz + lowDifference.xyz;\n return vec4(position, 1.);\n }\n#endif\n\n\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n #include <beginnormal_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n // #include <defaultnormal_vertex> // COMMENTED CHUNK\n vec3 transformedNormal = objectNormal;\n #ifdef USE_INSTANCING\n\n // this is in lieu of a per-instance normal-matrix\n // shear transforms in the instance matrix are not supported\n mat3 m = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n transformedNormal = m * transformedNormal;\n \n /* If we have negative scaling, we flip the normal */\n float signDet = sign(dot(m[0], cross(m[1], m[2])));\n // Optional fallback: treat 0 as +1\n signDet = signDet + (1.0 - abs(signDet));\n transformedNormal *= signDet;\n #endif\n transformedNormal = normalMatrix * transformedNormal;\n #ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n #endif\n #ifdef USE_TANGENT\n vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n #endif\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t//#include <project_vertex> // EDITED CHUNK\n #ifdef TRANSFORM_STORAGE\n vec4 tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale;\n objectTransform(tQuaternion, tPivotLow, tPivotHigh, tTranslation, tScale);\n #endif\n #ifdef USE_RTE\n vec4 position_lowT = vec4(position_low, 1.);\n vec4 position_highT = vec4(position, 1.);\n const vec3 ZERO3 = vec3(0., 0., 0.);\n\n highp vec4 rteLocalPosition = computeRelativePosition(position_lowT.xyz, position_highT.xyz, uViewer_low, uViewer_high);\n #ifdef TRANSFORM_STORAGE\n highp vec4 rtePivot = computeRelativePosition(tPivotLow.xyz, tPivotHigh.xyz, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = rotate_scaled_vertex_position_delta(rteLocalPosition, rtePivot, tScale, tQuaternion) + rtePivot.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n vec4 instancePivot = computeRelativePosition(ZERO3, ZERO3, uViewer_low, uViewer_high);\n rteLocalPosition.xyz = (mat3(instanceMatrix) * (rteLocalPosition - instancePivot).xyz) + instancePivot.xyz + instanceMatrix[3].xyz;\n #endif\n #endif\n\n #ifdef USE_RTE\n vec4 mvPosition = rteLocalPosition;\n #else\n vec4 mvPosition = vec4( transformed, 1.0 );\n #ifdef TRANSFORM_STORAGE\n mvPosition.xyz = rotate_scaled_vertex_position_delta(mvPosition, tPivotHigh, tScale, tQuaternion) + tPivotHigh.xyz + tTranslation.xyz;\n #endif\n #ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n #endif\n #endif\n \n #ifdef USE_RTE\n mvPosition = rteModelViewMatrix * mvPosition;\n #else\n mvPosition = modelViewMatrix * mvPosition;\n #endif\n \n #ifdef LINEAR_DEPTH\n vViewPosition = mvPosition;\n #endif \n vNormal = normalize( transformedNormal );\n gl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t// #include <clipping_planes_vertex>\n #if NUM_CLIPPING_PLANES > 0\n\t vClipPosition = - mvPosition.xyz;\n #endif\n\tvHighPrecisionZW = gl_Position.zw;\n}\n";
|