@operato/scene-visualizer 1.2.29 → 1.2.31
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/CHANGELOG.md +19 -0
- package/db.sqlite +0 -0
- package/dist/effects/outline.js +2 -1
- package/dist/effects/outline.js.map +1 -1
- package/dist/rack-table.d.ts +2 -1
- package/dist/rack-table.js +39 -23
- package/dist/rack-table.js.map +1 -1
- package/dist/rack.d.ts +7 -7
- package/dist/rack.js +35 -42
- package/dist/rack.js.map +1 -1
- package/dist/three-container-editor.d.ts +22 -0
- package/dist/three-container-editor.js +132 -0
- package/dist/three-container-editor.js.map +1 -0
- package/dist/three-container.js +8 -5
- package/dist/three-container.js.map +1 -1
- package/dist/three-controls.js +0 -8
- package/dist/three-controls.js.map +1 -1
- package/dist/threed/real-object.js +2 -1
- package/dist/threed/real-object.js.map +1 -1
- package/dist/threed/texture/canvas-texture.js +2 -1
- package/dist/threed/texture/canvas-texture.js.map +1 -1
- package/dist/visualizer.js +0 -6
- package/dist/visualizer.js.map +1 -1
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +26 -6
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +30 -0
- package/logs/application-2023-04-30-10.log +6 -0
- package/logs/application-2023-04-30-12.log +6 -0
- package/logs/application-2023-04-30-14.log +6 -0
- package/logs/application-2023-04-30-16.log +15 -0
- package/logs/application-2023-04-30-20.log +6 -0
- package/logs/application-2023-04-30-22.log +6 -0
- package/logs/connections-2023-04-30-10.log +41 -0
- package/logs/connections-2023-04-30-12.log +41 -0
- package/logs/connections-2023-04-30-14.log +41 -0
- package/logs/connections-2023-04-30-16.log +41 -0
- package/logs/connections-2023-04-30-20.log +41 -0
- package/logs/connections-2023-04-30-22.log +41 -0
- package/package.json +4 -4
- package/src/effects/outline.ts +2 -1
- package/src/rack-table.ts +56 -31
- package/src/rack.ts +52 -46
- package/src/three-container-editor.ts +187 -0
- package/src/three-container.ts +10 -6
- package/src/three-controls.ts +0 -9
- package/src/threed/real-object.ts +2 -1
- package/src/threed/texture/canvas-texture.ts +2 -1
- package/src/visualizer.ts +0 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/logs/application-2023-04-24-13.log +0 -15
- package/logs/application-2023-04-24-14.log +0 -12
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
|
|
3
|
+
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'
|
|
4
|
+
import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js'
|
|
5
|
+
|
|
6
|
+
export class ThreeContainerEditor {
|
|
7
|
+
private ortho: THREE.OrthographicCamera
|
|
8
|
+
private persp: THREE.PerspectiveCamera
|
|
9
|
+
|
|
10
|
+
private scene: THREE.Scene
|
|
11
|
+
private camera: THREE.Camera
|
|
12
|
+
private renderer: THREE.Renderer
|
|
13
|
+
|
|
14
|
+
private orbit?: OrbitControls
|
|
15
|
+
private transform?: TransformControls
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
scene: THREE.Scene,
|
|
19
|
+
ortho: THREE.OrthographicCamera,
|
|
20
|
+
persp: THREE.PerspectiveCamera,
|
|
21
|
+
camera: THREE.Camera,
|
|
22
|
+
renderer: THREE.Renderer
|
|
23
|
+
) {
|
|
24
|
+
this.ortho = ortho
|
|
25
|
+
this.persp = persp
|
|
26
|
+
|
|
27
|
+
this.scene = scene
|
|
28
|
+
this.camera = camera
|
|
29
|
+
this.renderer = renderer
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
dispose() {
|
|
33
|
+
this.orbit?.dispose()
|
|
34
|
+
this.transform?.dispose()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get orbitControls(): OrbitControls {
|
|
38
|
+
if (!this.orbit) {
|
|
39
|
+
this.orbit = new OrbitControls(this.camera!, this.renderer.domElement)
|
|
40
|
+
this.orbit.update()
|
|
41
|
+
|
|
42
|
+
this.orbit.addEventListener('change', this.render)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return this.orbit
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get transformControls(): TransformControls {
|
|
49
|
+
if (!this.transform) {
|
|
50
|
+
this.transform = new TransformControls(this.camera!, this.renderer.domElement)
|
|
51
|
+
this.transform.addEventListener('change', this.render)
|
|
52
|
+
|
|
53
|
+
this.transform.addEventListener('dragging-changed', event => {
|
|
54
|
+
this.orbitControls.enabled = !event.value
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return this.transform
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
attach(target: THREE.Object3D) {
|
|
62
|
+
this.transform?.attach(target)
|
|
63
|
+
this.scene.add(this.transformControls)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
detach() {
|
|
67
|
+
this.scene.remove(this.transformControls)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
onKeyDown(e: KeyboardEvent) {
|
|
71
|
+
switch (e.code) {
|
|
72
|
+
case 'KeyQ':
|
|
73
|
+
this.transformControls.setSpace(this.transformControls.space === 'local' ? 'world' : 'local')
|
|
74
|
+
break
|
|
75
|
+
|
|
76
|
+
case 'ShiftLeft':
|
|
77
|
+
case 'ShiftRight':
|
|
78
|
+
this.transformControls.setTranslationSnap(100)
|
|
79
|
+
this.transformControls.setRotationSnap(THREE.MathUtils.degToRad(15))
|
|
80
|
+
this.transformControls.setScaleSnap(0.25)
|
|
81
|
+
break
|
|
82
|
+
|
|
83
|
+
case 'KeyW':
|
|
84
|
+
this.transformControls.setMode('translate')
|
|
85
|
+
break
|
|
86
|
+
|
|
87
|
+
case 'KeyE':
|
|
88
|
+
this.transformControls.setMode('rotate')
|
|
89
|
+
break
|
|
90
|
+
|
|
91
|
+
case 'KeyR':
|
|
92
|
+
this.transformControls.setMode('scale')
|
|
93
|
+
break
|
|
94
|
+
|
|
95
|
+
case 'KeyC':
|
|
96
|
+
const position = this.camera.position.clone()
|
|
97
|
+
|
|
98
|
+
this.camera = (this.camera as THREE.PerspectiveCamera).isPerspectiveCamera ? this.ortho : this.persp
|
|
99
|
+
this.camera.position.copy(position)
|
|
100
|
+
|
|
101
|
+
this.orbitControls.object = this.camera
|
|
102
|
+
this.transformControls.camera = this.camera
|
|
103
|
+
|
|
104
|
+
this.camera.lookAt(this.orbitControls.target.x, this.orbitControls.target.y, this.orbitControls.target.z)
|
|
105
|
+
|
|
106
|
+
this.onWindowResize()
|
|
107
|
+
|
|
108
|
+
break
|
|
109
|
+
|
|
110
|
+
case 'KeyV':
|
|
111
|
+
const randomFoV = Math.random() + 0.1
|
|
112
|
+
const randomZoom = Math.random() + 0.1
|
|
113
|
+
|
|
114
|
+
this.persp.fov = randomFoV * 160
|
|
115
|
+
this.ortho.bottom = -randomFoV * 500
|
|
116
|
+
this.ortho.top = randomFoV * 500
|
|
117
|
+
|
|
118
|
+
this.persp.zoom = randomZoom * 5
|
|
119
|
+
this.ortho.zoom = randomZoom * 5
|
|
120
|
+
|
|
121
|
+
this.onWindowResize()
|
|
122
|
+
|
|
123
|
+
break
|
|
124
|
+
|
|
125
|
+
case 'Equal':
|
|
126
|
+
case 'NumpadAdd':
|
|
127
|
+
case 'NumpadEqual':
|
|
128
|
+
this.transformControls.setSize(this.transformControls.size + 0.1)
|
|
129
|
+
break
|
|
130
|
+
|
|
131
|
+
case 'Minus': // -
|
|
132
|
+
case 'IntlRo': // _
|
|
133
|
+
case 'NumpadSubtract': // num-
|
|
134
|
+
this.transformControls.setSize(Math.max(this.transformControls.size - 0.1, 0.1))
|
|
135
|
+
break
|
|
136
|
+
|
|
137
|
+
case 'KeyX':
|
|
138
|
+
this.transformControls.showX = !this.transformControls.showX
|
|
139
|
+
break
|
|
140
|
+
|
|
141
|
+
case 'KeyY':
|
|
142
|
+
this.transformControls.showY = !this.transformControls.showY
|
|
143
|
+
break
|
|
144
|
+
|
|
145
|
+
case 'KeyZ':
|
|
146
|
+
this.transformControls.showZ = !this.transformControls.showZ
|
|
147
|
+
break
|
|
148
|
+
|
|
149
|
+
case 'Space':
|
|
150
|
+
this.transformControls.enabled = !this.transformControls.enabled
|
|
151
|
+
break
|
|
152
|
+
|
|
153
|
+
case 'Esc':
|
|
154
|
+
this.transformControls.reset()
|
|
155
|
+
break
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
onKeyUp(e: KeyboardEvent) {
|
|
160
|
+
switch (e.code) {
|
|
161
|
+
case 'Shift':
|
|
162
|
+
this.transformControls.setTranslationSnap(null)
|
|
163
|
+
this.transformControls.setRotationSnap(null)
|
|
164
|
+
this.transformControls.setScaleSnap(null)
|
|
165
|
+
break
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
onWindowResize() {
|
|
170
|
+
const aspect = window.innerWidth / window.innerHeight
|
|
171
|
+
|
|
172
|
+
this.persp.aspect = aspect
|
|
173
|
+
this.persp.updateProjectionMatrix()
|
|
174
|
+
|
|
175
|
+
this.ortho.left = this.ortho.bottom * aspect
|
|
176
|
+
this.ortho.right = this.ortho.top * aspect
|
|
177
|
+
this.ortho.updateProjectionMatrix()
|
|
178
|
+
|
|
179
|
+
this.renderer.setSize(window.innerWidth, window.innerHeight)
|
|
180
|
+
|
|
181
|
+
this.render()
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
render() {
|
|
185
|
+
this.renderer.render(this.scene, this.camera)
|
|
186
|
+
}
|
|
187
|
+
}
|
package/src/three-container.ts
CHANGED
|
@@ -135,6 +135,10 @@ export class ThreeContainer extends Container implements ThreeDimensionalContain
|
|
|
135
135
|
|
|
136
136
|
if (this._renderer3d) this._renderer3d.clear()
|
|
137
137
|
|
|
138
|
+
if (this._controls?.autoRotate) {
|
|
139
|
+
this._controls.doAutoRotate(false)
|
|
140
|
+
}
|
|
141
|
+
|
|
138
142
|
delete this._renderer3d
|
|
139
143
|
delete this._camera
|
|
140
144
|
delete this._controls
|
|
@@ -194,11 +198,6 @@ export class ThreeContainer extends Container implements ThreeDimensionalContain
|
|
|
194
198
|
this._camera.lookAt(this._scene3d.position)
|
|
195
199
|
this._camera.zoom = this.getState('zoom') * 0.01
|
|
196
200
|
|
|
197
|
-
if (this.state.showAxis) {
|
|
198
|
-
var axisHelper = new THREE.AxesHelper(width)
|
|
199
|
-
this._scene3d.add(axisHelper)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
201
|
try {
|
|
203
202
|
const canvas = document.createElement('canvas')
|
|
204
203
|
let context = canvas!.getContext('webgl2')!
|
|
@@ -218,8 +217,8 @@ export class ThreeContainer extends Container implements ThreeDimensionalContain
|
|
|
218
217
|
this._renderer3d = renderer3d
|
|
219
218
|
|
|
220
219
|
renderer3d!.autoClear = true
|
|
221
|
-
renderer3d!.outputEncoding = THREE.sRGBEncoding
|
|
222
220
|
// @ts-ignore for three@0.150.1
|
|
221
|
+
renderer3d!.outputColorSpace = THREE.SRGBColorSpace
|
|
223
222
|
renderer3d!.useLegacyLights = false
|
|
224
223
|
renderer3d!.toneMappingExposure = Math.pow(exposure, 5.0)
|
|
225
224
|
renderer3d!.toneMapping = THREE.LinearToneMapping
|
|
@@ -329,6 +328,11 @@ export class ThreeContainer extends Container implements ThreeDimensionalContain
|
|
|
329
328
|
}
|
|
330
329
|
|
|
331
330
|
this._controls.update()
|
|
331
|
+
|
|
332
|
+
if (this.state.autoRotate) {
|
|
333
|
+
this.invalidate()
|
|
334
|
+
}
|
|
335
|
+
|
|
332
336
|
this.render_threed()
|
|
333
337
|
}
|
|
334
338
|
|
package/src/three-controls.ts
CHANGED
|
@@ -144,13 +144,7 @@ var ThreeControls = function (this: any, object: THREE.Camera, component: Compon
|
|
|
144
144
|
spherical.setFromVector3(offset)
|
|
145
145
|
|
|
146
146
|
if (scope.autoRotate && state === STATE.NONE) {
|
|
147
|
-
// theta = getAutoRotationAngle();
|
|
148
|
-
// thetaDelta = - getAutoRotationAngle();
|
|
149
|
-
// theta = 0;
|
|
150
|
-
|
|
151
147
|
rotateLeft(getAutoRotationAngle())
|
|
152
|
-
scope.component.invalidate()
|
|
153
|
-
// spherical.theta = getAutoRotationAngle();
|
|
154
148
|
}
|
|
155
149
|
|
|
156
150
|
spherical.theta += sphericalDelta.theta
|
|
@@ -213,9 +207,6 @@ var ThreeControls = function (this: any, object: THREE.Camera, component: Compon
|
|
|
213
207
|
return true
|
|
214
208
|
}
|
|
215
209
|
|
|
216
|
-
// if (this.autoRotate) {
|
|
217
|
-
// scope.component.invalidate()
|
|
218
|
-
// }
|
|
219
210
|
return false
|
|
220
211
|
}
|
|
221
212
|
})()
|
|
@@ -26,7 +26,8 @@ export abstract class RealObject<T extends THREE.Object3D = THREE.Object3D> {
|
|
|
26
26
|
component.app.url(fillStyle.image),
|
|
27
27
|
texture => {
|
|
28
28
|
texture.minFilter = THREE.LinearFilter
|
|
29
|
-
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
texture.colorSpace = THREE.SRGBColorSpace
|
|
30
31
|
texture.repeat.set(1, 1)
|
|
31
32
|
texture.needsUpdate = true
|
|
32
33
|
|
|
@@ -23,7 +23,8 @@ export function createCanvasTexture(component: Component): THREE.Texture {
|
|
|
23
23
|
texture.repeat.set(1, 1)
|
|
24
24
|
texture.magFilter = THREE.NearestFilter
|
|
25
25
|
texture.minFilter = THREE.LinearMipMapLinearFilter
|
|
26
|
-
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
texture.colorSpace = THREE.SRGBColorSpace
|
|
27
28
|
|
|
28
29
|
return texture
|
|
29
30
|
}
|
package/src/visualizer.ts
CHANGED