@luma.gl/engine 9.4.0-alpha.3 → 9.4.0-beta.1
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/LICENSE +5 -1
- package/dist/animation/animation-clip.d.ts +18 -0
- package/dist/animation/animation-clip.d.ts.map +1 -0
- package/dist/animation/animation-clip.js +15 -0
- package/dist/animation/animation-clip.js.map +1 -0
- package/dist/animation/animation-interpolation.d.ts +18 -0
- package/dist/animation/animation-interpolation.d.ts.map +1 -0
- package/dist/animation/animation-interpolation.js +101 -0
- package/dist/animation/animation-interpolation.js.map +1 -0
- package/dist/animation/animation-mixer.d.ts +88 -0
- package/dist/animation/animation-mixer.d.ts.map +1 -0
- package/dist/animation/animation-mixer.js +287 -0
- package/dist/animation/animation-mixer.js.map +1 -0
- package/dist/animation/animation-track.d.ts +42 -0
- package/dist/animation/animation-track.d.ts.map +1 -0
- package/dist/animation/animation-track.js +34 -0
- package/dist/animation/animation-track.js.map +1 -0
- package/dist/animation/animator.js +1 -1
- package/dist/animation/animator.js.map +1 -1
- package/dist/animation/key-frames.js +1 -1
- package/dist/animation/key-frames.js.map +1 -1
- package/dist/animation/morph-targets.d.ts +15 -0
- package/dist/animation/morph-targets.d.ts.map +1 -0
- package/dist/animation/morph-targets.js +151 -0
- package/dist/animation/morph-targets.js.map +1 -0
- package/dist/animation/skin.d.ts +18 -0
- package/dist/animation/skin.d.ts.map +1 -0
- package/dist/animation/skin.js +30 -0
- package/dist/animation/skin.js.map +1 -0
- package/dist/animation/timeline.js +1 -1
- package/dist/animation/timeline.js.map +1 -1
- package/dist/animation-loop/animation-loop-template.js +1 -1
- package/dist/animation-loop/animation-loop-template.js.map +1 -1
- package/dist/animation-loop/animation-loop.d.ts +5 -4
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +3 -3
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/animation-props.d.ts +1 -1
- package/dist/animation-loop/animation-props.js +1 -1
- package/dist/animation-loop/animation-props.js.map +1 -1
- package/dist/animation-loop/make-animation-loop.d.ts +9 -1
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +24 -5
- package/dist/animation-loop/make-animation-loop.js.map +1 -1
- package/dist/animation-loop/request-animation-frame.js +1 -1
- package/dist/animation-loop/request-animation-frame.js.map +1 -1
- package/dist/application-utils/load-file.js +1 -1
- package/dist/application-utils/load-file.js.map +1 -1
- package/dist/application-utils/random.js +1 -1
- package/dist/application-utils/random.js.map +1 -1
- package/dist/compute/buffer-transform.d.ts +1 -1
- package/dist/compute/buffer-transform.d.ts.map +1 -1
- package/dist/compute/buffer-transform.js +1 -1
- package/dist/compute/buffer-transform.js.map +1 -1
- package/dist/compute/computation.d.ts +4 -1
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +34 -15
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/swap.js +1 -1
- package/dist/compute/swap.js.map +1 -1
- package/dist/compute/texture-transform.js +1 -1
- package/dist/compute/texture-transform.js.map +1 -1
- package/dist/controls/orbit-controls.d.ts +61 -0
- package/dist/controls/orbit-controls.d.ts.map +1 -0
- package/dist/controls/orbit-controls.js +179 -0
- package/dist/controls/orbit-controls.js.map +1 -0
- package/dist/debug/copy-texture-to-image.js +1 -1
- package/dist/debug/copy-texture-to-image.js.map +1 -1
- package/dist/debug/debug-framebuffer.js +1 -1
- package/dist/debug/debug-framebuffer.js.map +1 -1
- package/dist/debug/debug-shader-layout.js +1 -1
- package/dist/debug/debug-shader-layout.js.map +1 -1
- package/dist/debug/pixel-data-utils.js +1 -1
- package/dist/debug/pixel-data-utils.js.map +1 -1
- package/dist/dist.dev.js +7605 -6249
- package/dist/dist.min.js +31 -31
- package/dist/dynamic-buffer/dynamic-buffer.js +1 -1
- package/dist/dynamic-buffer/dynamic-buffer.js.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.js +3 -2
- package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
- package/dist/dynamic-texture/texture-binding-source.js +1 -1
- package/dist/dynamic-texture/texture-binding-source.js.map +1 -1
- package/dist/dynamic-texture/texture-data.js +1 -1
- package/dist/dynamic-texture/texture-data.js.map +1 -1
- package/dist/dynamic-texture/video-texture.js +1 -1
- package/dist/dynamic-texture/video-texture.js.map +1 -1
- package/dist/geometries/cone-geometry.js +1 -1
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cube-geometry.js +1 -1
- package/dist/geometries/cube-geometry.js.map +1 -1
- package/dist/geometries/cylinder-geometry.js +1 -1
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +1 -1
- package/dist/geometries/ico-sphere-geometry.js.map +1 -1
- package/dist/geometry/geometry-table.js +1 -1
- package/dist/geometry/geometry-table.js.map +1 -1
- package/dist/geometry/geometry-utils.js +1 -1
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.js +1 -1
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.js +1 -1
- package/dist/geometry/gpu-geometry.js.map +1 -1
- package/dist/geometry/mesh-simplification.d.ts +29 -0
- package/dist/geometry/mesh-simplification.d.ts.map +1 -0
- package/dist/geometry/mesh-simplification.js +402 -0
- package/dist/geometry/mesh-simplification.js.map +1 -0
- package/dist/index.cjs +9874 -1407
- package/dist/index.cjs.map +3 -4
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/material/material-factory.js +1 -1
- package/dist/material/material-factory.js.map +1 -1
- package/dist/material/material.js +1 -1
- package/dist/material/material.js.map +1 -1
- package/dist/model/model.d.ts +1 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +35 -10
- package/dist/model/model.js.map +1 -1
- package/dist/model/split-uniforms-and-bindings.js +1 -1
- package/dist/model/split-uniforms-and-bindings.js.map +1 -1
- package/dist/models/billboard-texture-model.js +1 -1
- package/dist/models/billboard-texture-model.js.map +1 -1
- package/dist/models/billboard-texture-module.js +1 -1
- package/dist/models/billboard-texture-module.js.map +1 -1
- package/dist/models/clip-space.js +1 -1
- package/dist/models/clip-space.js.map +1 -1
- package/dist/models/directional-light-model.js +1 -1
- package/dist/models/directional-light-model.js.map +1 -1
- package/dist/models/light-model-utils.js +1 -1
- package/dist/models/light-model-utils.js.map +1 -1
- package/dist/models/point-light-model.js +1 -1
- package/dist/models/point-light-model.js.map +1 -1
- package/dist/models/spot-light-model.js +1 -1
- package/dist/models/spot-light-model.js.map +1 -1
- package/dist/modules/picking/color-picking.js +1 -1
- package/dist/modules/picking/color-picking.js.map +1 -1
- package/dist/modules/picking/index-color-picking.js +1 -1
- package/dist/modules/picking/index-color-picking.js.map +1 -1
- package/dist/modules/picking/index-picking.js +1 -1
- package/dist/modules/picking/index-picking.js.map +1 -1
- package/dist/modules/picking/legacy-color-picking.js +1 -1
- package/dist/modules/picking/legacy-color-picking.js.map +1 -1
- package/dist/modules/picking/legacy-picking-manager.js +1 -1
- package/dist/modules/picking/legacy-picking-manager.js.map +1 -1
- package/dist/modules/picking/picking-manager.js +1 -1
- package/dist/modules/picking/picking-manager.js.map +1 -1
- package/dist/modules/picking/picking-uniforms.js +1 -1
- package/dist/modules/picking/picking-uniforms.js.map +1 -1
- package/dist/modules/picking/picking.js +1 -1
- package/dist/modules/picking/picking.js.map +1 -1
- package/dist/passes/get-fragment-shader.js +1 -1
- package/dist/passes/get-fragment-shader.js.map +1 -1
- package/dist/passes/shader-pass-renderer.d.ts +19 -1
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +180 -11
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/passes/texture-transform-module.js +1 -1
- package/dist/passes/texture-transform-module.js.map +1 -1
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +7 -1
- package/dist/scenegraph/group-node.js.map +1 -1
- package/dist/scenegraph/model-node.js +1 -1
- package/dist/scenegraph/model-node.js.map +1 -1
- package/dist/scenegraph/scenegraph-bounds.js +1 -1
- package/dist/scenegraph/scenegraph-bounds.js.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +4 -4
- package/dist/scenegraph/scenegraph-node.js.map +1 -1
- package/dist/shader-inputs.js +1 -1
- package/dist/shader-inputs.js.map +1 -1
- package/dist/utils/buffer-layout-helper.js +1 -1
- package/dist/utils/buffer-layout-helper.js.map +1 -1
- package/dist/utils/buffer-layout-order.js +1 -1
- package/dist/utils/buffer-layout-order.js.map +1 -1
- package/dist/utils/deep-equal.js +1 -1
- package/dist/utils/deep-equal.js.map +1 -1
- package/dist/utils/shader-module-utils.js +1 -1
- package/dist/utils/shader-module-utils.js.map +1 -1
- package/dist/utils/uid.js +1 -1
- package/dist/utils/uid.js.map +1 -1
- package/package.json +2 -2
- package/src/animation/animation-clip.ts +28 -0
- package/src/animation/animation-interpolation.ts +175 -0
- package/src/animation/animation-mixer.ts +370 -0
- package/src/animation/animation-track.ts +70 -0
- package/src/animation/animator.ts +1 -1
- package/src/animation/key-frames.ts +1 -1
- package/src/animation/morph-targets.ts +191 -0
- package/src/animation/skin.ts +50 -0
- package/src/animation/timeline.ts +1 -1
- package/src/animation-loop/animation-loop-template.ts +1 -1
- package/src/animation-loop/animation-loop.ts +8 -7
- package/src/animation-loop/animation-props.ts +2 -2
- package/src/animation-loop/make-animation-loop.ts +36 -6
- package/src/animation-loop/request-animation-frame.ts +1 -1
- package/src/application-utils/load-file.ts +1 -1
- package/src/application-utils/random.ts +1 -1
- package/src/compute/buffer-transform.ts +2 -2
- package/src/compute/computation.ts +47 -20
- package/src/compute/swap.ts +1 -1
- package/src/compute/texture-transform.ts +1 -1
- package/src/controls/orbit-controls.ts +248 -0
- package/src/debug/copy-texture-to-image.ts +1 -1
- package/src/debug/debug-framebuffer.ts +1 -1
- package/src/debug/debug-shader-layout.ts +1 -1
- package/src/debug/pixel-data-utils.ts +1 -1
- package/src/dynamic-buffer/dynamic-buffer.ts +1 -1
- package/src/dynamic-texture/dynamic-texture.ts +3 -2
- package/src/dynamic-texture/texture-binding-source.ts +1 -1
- package/src/dynamic-texture/texture-data.ts +1 -1
- package/src/dynamic-texture/video-texture.ts +1 -1
- package/src/geometries/cone-geometry.ts +1 -1
- package/src/geometries/cube-geometry.ts +1 -1
- package/src/geometries/cylinder-geometry.ts +1 -1
- package/src/geometries/ico-sphere-geometry.ts +1 -1
- package/src/geometry/geometry-table.ts +1 -1
- package/src/geometry/geometry-utils.ts +1 -1
- package/src/geometry/geometry.ts +1 -1
- package/src/geometry/gpu-geometry.ts +1 -1
- package/src/geometry/mesh-simplification.ts +554 -0
- package/src/index.ts +32 -1
- package/src/material/material-factory.ts +1 -1
- package/src/material/material.ts +1 -1
- package/src/model/model.ts +67 -12
- package/src/model/split-uniforms-and-bindings.ts +1 -1
- package/src/models/billboard-texture-model.ts +1 -1
- package/src/models/billboard-texture-module.ts +1 -1
- package/src/models/clip-space.ts +1 -1
- package/src/models/directional-light-model.ts +1 -1
- package/src/models/light-model-utils.ts +1 -1
- package/src/models/point-light-model.ts +1 -1
- package/src/models/spot-light-model.ts +1 -1
- package/src/modules/picking/color-picking.ts +1 -1
- package/src/modules/picking/index-color-picking.ts +1 -1
- package/src/modules/picking/index-picking.ts +1 -1
- package/src/modules/picking/legacy-color-picking.ts +1 -1
- package/src/modules/picking/legacy-picking-manager.ts +1 -1
- package/src/modules/picking/picking-manager.ts +1 -1
- package/src/modules/picking/picking-uniforms.ts +1 -1
- package/src/modules/picking/picking.ts +1 -1
- package/src/passes/get-fragment-shader.ts +1 -1
- package/src/passes/shader-pass-renderer.ts +246 -14
- package/src/passes/texture-transform-module.ts +1 -1
- package/src/scenegraph/group-node.ts +8 -1
- package/src/scenegraph/model-node.ts +1 -1
- package/src/scenegraph/scenegraph-bounds.ts +1 -1
- package/src/scenegraph/scenegraph-node.ts +4 -4
- package/src/shader-inputs.ts +1 -1
- package/src/utils/buffer-layout-helper.ts +1 -1
- package/src/utils/buffer-layout-order.ts +1 -1
- package/src/utils/deep-equal.ts +1 -1
- package/src/utils/shader-module-utils.ts +1 -1
- package/src/utils/uid.ts +1 -1
package/src/compute/swap.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {BufferProps, FramebufferProps} from '@luma.gl/core';
|
|
6
6
|
import {Device, Resource, Buffer, Framebuffer, Texture} from '@luma.gl/core';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {Buffer, Device, Framebuffer, RenderPassProps, Sampler, Texture} from '@luma.gl/core';
|
|
6
6
|
import {getPassthroughFS} from '@luma.gl/shadertools';
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export type OrbitPosition = [number, number, number];
|
|
6
|
+
|
|
7
|
+
export type OrbitControlsProps = {
|
|
8
|
+
target?: Readonly<OrbitPosition>;
|
|
9
|
+
distance?: number;
|
|
10
|
+
yaw?: number;
|
|
11
|
+
pitch?: number;
|
|
12
|
+
minDistance?: number;
|
|
13
|
+
maxDistance?: number;
|
|
14
|
+
minPitch?: number;
|
|
15
|
+
maxPitch?: number;
|
|
16
|
+
rotateSpeed?: number;
|
|
17
|
+
pitchSpeed?: number;
|
|
18
|
+
zoomSpeed?: number;
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
enableZoom?: boolean;
|
|
21
|
+
enablePan?: boolean;
|
|
22
|
+
panSpeed?: number;
|
|
23
|
+
autoRotate?: boolean;
|
|
24
|
+
autoRotateSpeed?: number;
|
|
25
|
+
onInteractionStart?: () => void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type ResolvedOrbitControlsProps = Required<
|
|
29
|
+
Omit<OrbitControlsProps, 'pitchSpeed' | 'onInteractionStart'>
|
|
30
|
+
> &
|
|
31
|
+
Pick<OrbitControlsProps, 'pitchSpeed' | 'onInteractionStart'>;
|
|
32
|
+
|
|
33
|
+
const DEFAULT_PROPS: ResolvedOrbitControlsProps = {
|
|
34
|
+
target: [0, 0, 0],
|
|
35
|
+
distance: 10,
|
|
36
|
+
yaw: 0,
|
|
37
|
+
pitch: 0.25,
|
|
38
|
+
minDistance: 1,
|
|
39
|
+
maxDistance: 100,
|
|
40
|
+
minPitch: -Math.PI / 2 + 0.01,
|
|
41
|
+
maxPitch: Math.PI / 2 - 0.01,
|
|
42
|
+
rotateSpeed: 0.006,
|
|
43
|
+
zoomSpeed: 0.001,
|
|
44
|
+
enabled: true,
|
|
45
|
+
enableZoom: true,
|
|
46
|
+
enablePan: false,
|
|
47
|
+
panSpeed: 0.0018,
|
|
48
|
+
autoRotate: false,
|
|
49
|
+
autoRotateSpeed: 0.1
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Pointer orbit, wheel zoom, and optional automatic rotation controls for an HTML canvas.
|
|
54
|
+
*
|
|
55
|
+
* Call {@link update} once per frame with an animation-loop timestamp in milliseconds before
|
|
56
|
+
* reading {@link getEyePosition}. Manual dragging temporarily pauses automatic rotation and
|
|
57
|
+
* resumes it from the new angle when the pointer is released.
|
|
58
|
+
*/
|
|
59
|
+
export class OrbitControls {
|
|
60
|
+
readonly canvas: HTMLCanvasElement;
|
|
61
|
+
readonly props: ResolvedOrbitControlsProps;
|
|
62
|
+
yaw: number;
|
|
63
|
+
pitch: number;
|
|
64
|
+
distance: number;
|
|
65
|
+
|
|
66
|
+
private dragging = false;
|
|
67
|
+
private pointerId: number | null = null;
|
|
68
|
+
private lastPointer: [number, number] = [0, 0];
|
|
69
|
+
private previousTimeMilliseconds: number | null = null;
|
|
70
|
+
private readonly previousCursor: string;
|
|
71
|
+
private readonly previousTouchAction: string;
|
|
72
|
+
|
|
73
|
+
constructor(canvas: HTMLCanvasElement, props: OrbitControlsProps = {}) {
|
|
74
|
+
this.canvas = canvas;
|
|
75
|
+
this.props = {...DEFAULT_PROPS, ...props};
|
|
76
|
+
this.props.target = [...this.props.target];
|
|
77
|
+
this.yaw = this.props.yaw;
|
|
78
|
+
this.pitch = clampNumber(this.props.pitch, this.props.minPitch, this.props.maxPitch);
|
|
79
|
+
this.distance = clampNumber(
|
|
80
|
+
this.props.distance,
|
|
81
|
+
this.props.minDistance,
|
|
82
|
+
this.props.maxDistance
|
|
83
|
+
);
|
|
84
|
+
this.previousCursor = canvas.style.cursor;
|
|
85
|
+
this.previousTouchAction = canvas.style.touchAction;
|
|
86
|
+
canvas.style.cursor = 'grab';
|
|
87
|
+
canvas.style.touchAction = 'none';
|
|
88
|
+
canvas.addEventListener('pointerdown', this.handlePointerDown);
|
|
89
|
+
canvas.addEventListener('pointermove', this.handlePointerMove);
|
|
90
|
+
canvas.addEventListener('pointerup', this.handlePointerUp);
|
|
91
|
+
canvas.addEventListener('pointercancel', this.handlePointerUp);
|
|
92
|
+
canvas.addEventListener('wheel', this.handleWheel, {passive: false});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Advances optional auto-rotation using an animation-loop timestamp in milliseconds. */
|
|
96
|
+
update(timeMilliseconds: number): void {
|
|
97
|
+
if (
|
|
98
|
+
this.previousTimeMilliseconds !== null &&
|
|
99
|
+
this.props.enabled &&
|
|
100
|
+
this.props.autoRotate &&
|
|
101
|
+
!this.dragging
|
|
102
|
+
) {
|
|
103
|
+
const deltaSeconds = Math.min(
|
|
104
|
+
Math.max(timeMilliseconds - this.previousTimeMilliseconds, 0) / 1000,
|
|
105
|
+
0.1
|
|
106
|
+
);
|
|
107
|
+
this.yaw += this.props.autoRotateSpeed * deltaSeconds;
|
|
108
|
+
}
|
|
109
|
+
this.previousTimeMilliseconds = timeMilliseconds;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Returns the current camera eye around the configured target. */
|
|
113
|
+
getEyePosition(): OrbitPosition {
|
|
114
|
+
const horizontalDistance = this.distance * Math.cos(this.pitch);
|
|
115
|
+
return [
|
|
116
|
+
this.props.target[0] + horizontalDistance * Math.sin(this.yaw),
|
|
117
|
+
this.props.target[1] + this.distance * Math.sin(this.pitch),
|
|
118
|
+
this.props.target[2] + horizontalDistance * Math.cos(this.yaw)
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Enables or pauses automatic rotation without losing the current manual angle. */
|
|
123
|
+
setAutoRotate(autoRotate: boolean): void {
|
|
124
|
+
this.props.autoRotate = autoRotate;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Updates orbit configuration and applies supplied camera state immediately. */
|
|
128
|
+
setProps(props: OrbitControlsProps): void {
|
|
129
|
+
Object.assign(this.props, props);
|
|
130
|
+
if (props.enabled === false && this.dragging) {
|
|
131
|
+
this.endPointerInteraction();
|
|
132
|
+
}
|
|
133
|
+
if (props.target) {
|
|
134
|
+
this.props.target = [...props.target];
|
|
135
|
+
}
|
|
136
|
+
if (props.yaw !== undefined) {
|
|
137
|
+
this.yaw = props.yaw;
|
|
138
|
+
}
|
|
139
|
+
if (props.pitch !== undefined || props.minPitch !== undefined || props.maxPitch !== undefined) {
|
|
140
|
+
this.pitch = clampNumber(props.pitch ?? this.pitch, this.props.minPitch, this.props.maxPitch);
|
|
141
|
+
}
|
|
142
|
+
if (
|
|
143
|
+
props.distance !== undefined ||
|
|
144
|
+
props.minDistance !== undefined ||
|
|
145
|
+
props.maxDistance !== undefined
|
|
146
|
+
) {
|
|
147
|
+
this.distance = clampNumber(
|
|
148
|
+
props.distance ?? this.distance,
|
|
149
|
+
this.props.minDistance,
|
|
150
|
+
this.props.maxDistance
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Restores the configured starting angle and zoom. */
|
|
156
|
+
reset(): void {
|
|
157
|
+
this.yaw = this.props.yaw;
|
|
158
|
+
this.pitch = clampNumber(this.props.pitch, this.props.minPitch, this.props.maxPitch);
|
|
159
|
+
this.distance = clampNumber(
|
|
160
|
+
this.props.distance,
|
|
161
|
+
this.props.minDistance,
|
|
162
|
+
this.props.maxDistance
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
destroy(): void {
|
|
167
|
+
this.canvas.removeEventListener('pointerdown', this.handlePointerDown);
|
|
168
|
+
this.canvas.removeEventListener('pointermove', this.handlePointerMove);
|
|
169
|
+
this.canvas.removeEventListener('pointerup', this.handlePointerUp);
|
|
170
|
+
this.canvas.removeEventListener('pointercancel', this.handlePointerUp);
|
|
171
|
+
this.canvas.removeEventListener('wheel', this.handleWheel);
|
|
172
|
+
if (this.pointerId !== null && this.canvas.hasPointerCapture(this.pointerId)) {
|
|
173
|
+
this.canvas.releasePointerCapture(this.pointerId);
|
|
174
|
+
}
|
|
175
|
+
this.canvas.style.cursor = this.previousCursor;
|
|
176
|
+
this.canvas.style.touchAction = this.previousTouchAction;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private readonly handlePointerDown = (event: PointerEvent): void => {
|
|
180
|
+
if (!this.props.enabled || event.button !== 0) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
this.props.onInteractionStart?.();
|
|
184
|
+
this.dragging = true;
|
|
185
|
+
this.pointerId = event.pointerId;
|
|
186
|
+
this.lastPointer = [event.clientX, event.clientY];
|
|
187
|
+
this.canvas.setPointerCapture(event.pointerId);
|
|
188
|
+
this.canvas.style.cursor = 'grabbing';
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
private readonly handlePointerMove = (event: PointerEvent): void => {
|
|
192
|
+
if (!this.props.enabled || !this.dragging || event.pointerId !== this.pointerId) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const deltaX = event.clientX - this.lastPointer[0];
|
|
196
|
+
const deltaY = event.clientY - this.lastPointer[1];
|
|
197
|
+
this.lastPointer = [event.clientX, event.clientY];
|
|
198
|
+
if (this.props.enablePan && event.shiftKey) {
|
|
199
|
+
const panScale = this.distance * this.props.panSpeed;
|
|
200
|
+
this.props.target = [
|
|
201
|
+
this.props.target[0] - Math.cos(this.yaw) * deltaX * panScale,
|
|
202
|
+
this.props.target[1] + deltaY * panScale,
|
|
203
|
+
this.props.target[2] + Math.sin(this.yaw) * deltaX * panScale
|
|
204
|
+
];
|
|
205
|
+
} else {
|
|
206
|
+
this.yaw -= deltaX * this.props.rotateSpeed;
|
|
207
|
+
this.pitch = clampNumber(
|
|
208
|
+
this.pitch - deltaY * (this.props.pitchSpeed ?? this.props.rotateSpeed),
|
|
209
|
+
this.props.minPitch,
|
|
210
|
+
this.props.maxPitch
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
private readonly handlePointerUp = (event: PointerEvent): void => {
|
|
216
|
+
if (event.pointerId !== this.pointerId) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this.endPointerInteraction();
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
private endPointerInteraction(): void {
|
|
223
|
+
this.dragging = false;
|
|
224
|
+
if (this.pointerId !== null && this.canvas.hasPointerCapture(this.pointerId)) {
|
|
225
|
+
this.canvas.releasePointerCapture(this.pointerId);
|
|
226
|
+
}
|
|
227
|
+
this.pointerId = null;
|
|
228
|
+
this.canvas.style.cursor = 'grab';
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
private readonly handleWheel = (event: WheelEvent): void => {
|
|
232
|
+
if (!this.props.enabled || !this.props.enableZoom) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
event.preventDefault();
|
|
236
|
+
this.props.onInteractionStart?.();
|
|
237
|
+
const deltaY = clampNumber(event.deltaY, -240, 240);
|
|
238
|
+
this.distance = clampNumber(
|
|
239
|
+
this.distance * Math.exp(deltaY * this.props.zoomSpeed),
|
|
240
|
+
this.props.minDistance,
|
|
241
|
+
this.props.maxDistance
|
|
242
|
+
);
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function clampNumber(value: number, minimum: number, maximum: number): number {
|
|
247
|
+
return Math.min(Math.max(value, minimum), maximum);
|
|
248
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {BufferMapCallback, BufferProps, Device, Binding as CoreBinding} from '@luma.gl/core';
|
|
6
6
|
import {Buffer} from '@luma.gl/core';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {Binding, BindingDeclaration, ComputeShaderLayout, ShaderLayout} from '@luma.gl/core';
|
|
6
6
|
import {getShaderLayoutBinding} from '@luma.gl/core';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {TypedArray, TextureFormat, ExternalImage} from '@luma.gl/core';
|
|
6
6
|
import {isExternalImage, getExternalImageSize} from '@luma.gl/core';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {Device, ExternalTexture, ResourceProps, Sampler, SamplerProps} from '@luma.gl/core';
|
|
6
6
|
import {Texture, assert} from '@luma.gl/core';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {TruncatedConeGeometryProps} from './truncated-cone-geometry';
|
|
6
6
|
import {TruncatedConeGeometry} from './truncated-cone-geometry';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {TruncatedConeGeometryProps} from './truncated-cone-geometry';
|
|
6
6
|
import {TruncatedConeGeometry} from './truncated-cone-geometry';
|
package/src/geometry/geometry.ts
CHANGED