@things-factory/scene-visualizer 6.0.1 → 6.0.5
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/package.json +2 -2
- package/src/index.js +2 -6
- package/src/mesh.js +1 -7
- package/src/object3d.js +1 -7
- package/src/rack-table-cell.js +4 -4
- package/src/visualizer.js +4 -49
- package/assets/canvasicon-cj-truck-small.png +0 -0
- package/assets/canvasicon-cj-truck.png +0 -0
- package/assets/canvasicon-conveyor.png +0 -0
- package/assets/canvasicon-inspection-desk.png +0 -0
- package/assets/canvasicon-pallet-jockey.png +0 -0
- package/assets/canvasicon-pallet.png +0 -0
- package/assets/canvasicon-worker-1.png +0 -0
- package/assets/canvasicon-worker-2.png +0 -0
- package/assets/canvasicon-worker-3.png +0 -0
- package/assets/cj-truck-small.png +0 -0
- package/assets/cj-truck.png +0 -0
- package/assets/glTF_100px.png +0 -0
- package/assets/inspection-desk.png +0 -0
- package/assets/pallet-jockey.png +0 -0
- package/assets/pallet.png +0 -0
- package/assets/pallet_symbol.png +0 -0
- package/assets/roller-conveyor.png +0 -0
- package/assets/worker-2.png +0 -0
- package/assets/worker-3.png +0 -0
- package/assets/worker.png +0 -0
- package/src/cone.js +0 -88
- package/src/door.js +0 -52
- package/src/floor.js +0 -162
- package/src/humidity-sensor.js +0 -267
- package/src/loaders/ColladaLoader.js +0 -3166
- package/src/loaders/TGALoader.js +0 -461
- package/src/mixins/visible.js +0 -185
- package/src/path.js +0 -167
- package/src/video-player-360.js +0 -460
- package/src/webgl-3d-viewer.js +0 -349
- package/templates/pallet-jockey.js +0 -20
- package/templates/roller-conveyor.js +0 -20
package/src/webgl-3d-viewer.js
DELETED
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
import * as THREE from 'three'
|
|
5
|
-
import ForkLift from './forkLift'
|
|
6
|
-
import Person from './person'
|
|
7
|
-
import Rack from './rack'
|
|
8
|
-
|
|
9
|
-
export default class WebGL3dViewer {
|
|
10
|
-
constructor(target, model, data) {
|
|
11
|
-
if (typeof target == 'string') this._container = document.getElementById(target)
|
|
12
|
-
else this._container = target
|
|
13
|
-
|
|
14
|
-
this._model = model
|
|
15
|
-
|
|
16
|
-
this.init()
|
|
17
|
-
|
|
18
|
-
// EVENTS
|
|
19
|
-
this.bindEvents()
|
|
20
|
-
|
|
21
|
-
this.run()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
init() {
|
|
25
|
-
var model = this._model
|
|
26
|
-
|
|
27
|
-
this.registerLoaders()
|
|
28
|
-
|
|
29
|
-
// PROPERTY
|
|
30
|
-
this._mouse = { x: 0, y: 0 }
|
|
31
|
-
this.INTERSECTED
|
|
32
|
-
|
|
33
|
-
this.FLOOR_WIDTH = model.width
|
|
34
|
-
this.FLOOR_HEIGHT = model.height
|
|
35
|
-
|
|
36
|
-
// SCENE
|
|
37
|
-
this._scene = new THREE.Scene()
|
|
38
|
-
|
|
39
|
-
// CAMERA
|
|
40
|
-
this.SCREEN_WIDTH = this._container.clientWidth
|
|
41
|
-
this.SCREEN_HEIGHT = this._container.clientHeight
|
|
42
|
-
this.VIEW_ANGLE = 45
|
|
43
|
-
this.ASPECT = this.SCREEN_WIDTH / this.SCREEN_HEIGHT
|
|
44
|
-
this.NEAR = 0.1
|
|
45
|
-
this.FAR = 20000
|
|
46
|
-
|
|
47
|
-
this._camera = new THREE.PerspectiveCamera(this.VIEW_ANGLE, this.ASPECT, this.NEAR, this.FAR)
|
|
48
|
-
this._scene.add(this._camera)
|
|
49
|
-
this._camera.position.set(800, 800, 800)
|
|
50
|
-
this._camera.lookAt(this._scene.position)
|
|
51
|
-
|
|
52
|
-
// RENDERER
|
|
53
|
-
if (this._renderer && this._renderer.domElement) {
|
|
54
|
-
this._container.removeChild(this._renderer.domElement)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
this._renderer = new THREE.WebGLRenderer({ precision: 'mediump' })
|
|
58
|
-
// this._renderer = new THREE.WebGLRenderer( {antialias:true, precision: 'mediump'} );
|
|
59
|
-
this._renderer.setClearColor('#424b57')
|
|
60
|
-
this._renderer.setSize(this.SCREEN_WIDTH, this.SCREEN_HEIGHT)
|
|
61
|
-
|
|
62
|
-
this._container.appendChild(this._renderer.domElement)
|
|
63
|
-
|
|
64
|
-
// KEYBOARD
|
|
65
|
-
this._keyboard = new THREEx.KeyboardState()
|
|
66
|
-
|
|
67
|
-
// CONTROLS
|
|
68
|
-
this._controls = new THREE.OrbitControls(this._camera, this._renderer.domElement)
|
|
69
|
-
|
|
70
|
-
// LIGHT
|
|
71
|
-
var light = new THREE.PointLight(0xffffff)
|
|
72
|
-
light.position.set(10, 10, 0)
|
|
73
|
-
this._camera.add(light)
|
|
74
|
-
|
|
75
|
-
this.createFloor()
|
|
76
|
-
|
|
77
|
-
////////////
|
|
78
|
-
// CUSTOM //
|
|
79
|
-
////////////
|
|
80
|
-
this.createObjects(model.components)
|
|
81
|
-
|
|
82
|
-
// initialize object to perform world/screen calculations
|
|
83
|
-
this._projector = new THREE.Projector()
|
|
84
|
-
|
|
85
|
-
this._loadManager = new THREE.LoadingManager()
|
|
86
|
-
this._loadManager.onProgress = function(item, loaded, total) {}
|
|
87
|
-
|
|
88
|
-
// this.loadExtMtl('obj/Casual_Man_02/', 'Casual_Man.mtl', '', function(materials){
|
|
89
|
-
// materials.preload();
|
|
90
|
-
//
|
|
91
|
-
// this.loadExtObj('obj/Casual_Man_02/', 'Casual_Man.obj', materials, function(object){
|
|
92
|
-
//
|
|
93
|
-
// object.position.x = 0;
|
|
94
|
-
// object.position.y = 0;
|
|
95
|
-
// object.position.z = 350;
|
|
96
|
-
// object.rotation.y = Math.PI;
|
|
97
|
-
// object.scale.set(15, 15, 15)
|
|
98
|
-
//
|
|
99
|
-
// this._scene.add(object);
|
|
100
|
-
// })
|
|
101
|
-
// })
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
registerLoaders() {
|
|
105
|
-
THREE.THREE.Loader.Handlers.add(/\.tga$/i, new THREE.TGALoader())
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
loadExtMtl(path, filename, texturePath, funcSuccess) {
|
|
109
|
-
var self = this
|
|
110
|
-
var mtlLoader = new THREE.MTLLoader()
|
|
111
|
-
mtlLoader.setPath(path)
|
|
112
|
-
if (texturePath) mtlLoader.setTexturePath(texturePath)
|
|
113
|
-
|
|
114
|
-
mtlLoader.load(filename, funcSuccess.bind(self))
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
loadExtObj(path, filename, materials, funcSuccess) {
|
|
118
|
-
var self = this
|
|
119
|
-
var loader = new THREE.OBJLoader(this._loadManager)
|
|
120
|
-
|
|
121
|
-
loader.setPath(path)
|
|
122
|
-
|
|
123
|
-
if (materials) loader.setMaterials(materials)
|
|
124
|
-
|
|
125
|
-
loader.load(
|
|
126
|
-
filename,
|
|
127
|
-
funcSuccess.bind(self),
|
|
128
|
-
function() {},
|
|
129
|
-
function() {
|
|
130
|
-
console.log('error')
|
|
131
|
-
}
|
|
132
|
-
)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
createFloor() {
|
|
136
|
-
// FLOOR
|
|
137
|
-
let model = this._model
|
|
138
|
-
let floorColor = model.color || '#7a8696'
|
|
139
|
-
|
|
140
|
-
// var floorTexture = new THREE.TextureLoader().load('textures/Light-gray-rough-concrete-wall-Seamless-background-photo-texture.jpg');
|
|
141
|
-
// floorTexture.wrapS = floorTexture.wrapT = THREE.RepeatWrapping;
|
|
142
|
-
// floorTexture.repeat.set( 1, 1 );
|
|
143
|
-
// var floorMaterial = new THREE.MeshStandardMaterial( { map: floorTexture, side: THREE.DoubleSide } );
|
|
144
|
-
var floorMaterial = new THREE.MeshStandardMaterial({ color: floorColor, side: THREE.DoubleSide })
|
|
145
|
-
var floorGeometry = new THREE.BoxBufferGeometry(this.FLOOR_WIDTH, this.FLOOR_HEIGHT, 1, 10, 10)
|
|
146
|
-
// var floorMaterial = new THREE.MeshStandardMaterial( { map: floorTexture, side: THREE.DoubleSide } );
|
|
147
|
-
// var floorGeometry = new THREE.PlaneGeometry(this.FLOOR_WIDTH, this.FLOOR_HEIGHT, 10, 10);
|
|
148
|
-
var floor = new THREE.Mesh(floorGeometry, floorMaterial)
|
|
149
|
-
floor.position.y = -1
|
|
150
|
-
floor.rotation.x = Math.PI / 2
|
|
151
|
-
this._scene.add(floor)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
createSkyBox() {
|
|
155
|
-
// SKYBOX/FOG
|
|
156
|
-
var skyBoxGeometry = new THREE.BoxBufferGeometry(10000, 10000, 10000)
|
|
157
|
-
var skyBoxMaterial = new THREE.MeshStandardMaterial({ color: 0x9999ff, side: THREE.BackSide })
|
|
158
|
-
var skyBox = new THREE.Mesh(skyBoxGeometry, skyBoxMaterial)
|
|
159
|
-
this._scene.add(skyBox)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async createObjects(models) {
|
|
163
|
-
let scene = this._scene
|
|
164
|
-
let model = this._model
|
|
165
|
-
let canvasSize = {
|
|
166
|
-
width: this.FLOOR_WIDTH,
|
|
167
|
-
height: this.FLOOR_HEIGHT
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
var obj = new THREE.Object3D()
|
|
171
|
-
|
|
172
|
-
models.forEach(model => {
|
|
173
|
-
var item
|
|
174
|
-
switch (model.type) {
|
|
175
|
-
case 'rack':
|
|
176
|
-
item = new Rack(model, canvasSize)
|
|
177
|
-
break
|
|
178
|
-
|
|
179
|
-
case 'forklift':
|
|
180
|
-
item = new ForkLift(model, canvasSize)
|
|
181
|
-
|
|
182
|
-
break
|
|
183
|
-
case 'person':
|
|
184
|
-
item = new Person(model, canvasSize)
|
|
185
|
-
|
|
186
|
-
break
|
|
187
|
-
default:
|
|
188
|
-
break
|
|
189
|
-
}
|
|
190
|
-
obj.add(item)
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
scene.add(obj)
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
animate() {
|
|
197
|
-
this._animFrame = requestAnimationFrame(this.animate.bind(this))
|
|
198
|
-
this.rotateCam(0.015)
|
|
199
|
-
this.render()
|
|
200
|
-
this.update()
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
update() {
|
|
204
|
-
var tooltip = document.getElementById('tooltip')
|
|
205
|
-
|
|
206
|
-
// find intersections
|
|
207
|
-
|
|
208
|
-
// create a Ray with origin at the mouse position
|
|
209
|
-
// and direction into the scene (camera direction)
|
|
210
|
-
var vector = new THREE.Vector3(this._mouse.x, this._mouse.y, 1)
|
|
211
|
-
vector.unproject(this._camera)
|
|
212
|
-
var ray = new THREE.Raycaster(this._camera.position, vector.sub(this._camera.position).normalize())
|
|
213
|
-
|
|
214
|
-
// create an array containing all objects in the scene with which the ray intersects
|
|
215
|
-
var intersects = ray.intersectObjects(this._scene.children, true)
|
|
216
|
-
|
|
217
|
-
// INTERSECTED = the object in the scene currently closest to the camera
|
|
218
|
-
// and intersected by the Ray projected from the mouse position
|
|
219
|
-
|
|
220
|
-
// if there is one (or more) intersections
|
|
221
|
-
if (intersects.length > 0) {
|
|
222
|
-
// if the closest object intersected is not the currently stored intersection object
|
|
223
|
-
if (intersects[0].object != this.INTERSECTED) {
|
|
224
|
-
// restore previous intersection object (if it exists) to its original color
|
|
225
|
-
// if ( this.INTERSECTED )
|
|
226
|
-
// this.INTERSECTED.material.color.setHex( this.INTERSECTED.currentHex );
|
|
227
|
-
// store reference to closest object as current intersection object
|
|
228
|
-
this.INTERSECTED = intersects[0].object
|
|
229
|
-
// store color of closest object (for later restoration)
|
|
230
|
-
// this.INTERSECTED.currentHex = this.INTERSECTED.material.color.getHex();
|
|
231
|
-
// set a new color for closest object
|
|
232
|
-
// this.INTERSECTED.material.color.setHex( 0xffff00 );
|
|
233
|
-
|
|
234
|
-
if (this.INTERSECTED.type === 'stock') {
|
|
235
|
-
if (!this.INTERSECTED.visible) return
|
|
236
|
-
|
|
237
|
-
if (!this.INTERSECTED.userData) this.INTERSECTED.userData = {}
|
|
238
|
-
|
|
239
|
-
var loc = this.INTERSECTED.name
|
|
240
|
-
var status = this.INTERSECTED.userData.status
|
|
241
|
-
var boxId = this.INTERSECTED.userData.boxId
|
|
242
|
-
var inDate = this.INTERSECTED.userData.inDate
|
|
243
|
-
var type = this.INTERSECTED.userData.type
|
|
244
|
-
var count = this.INTERSECTED.userData.count
|
|
245
|
-
|
|
246
|
-
tooltip.textContent = ''
|
|
247
|
-
|
|
248
|
-
for (let key in this.INTERSECTED.userData) {
|
|
249
|
-
if (this.INTERSECTED.userData[key])
|
|
250
|
-
tooltip.textContent += key + ': ' + this.INTERSECTED.userData[key] + '\n'
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
var mouseX = ((this._mouse.x + 1) / 2) * this.SCREEN_WIDTH
|
|
254
|
-
var mouseY = ((-this._mouse.y + 1) / 2) * this.SCREEN_HEIGHT
|
|
255
|
-
|
|
256
|
-
tooltip.style.left = mouseX + 20 + 'px'
|
|
257
|
-
tooltip.style.top = mouseY - 20 + 'px'
|
|
258
|
-
tooltip.style.display = 'block'
|
|
259
|
-
} else {
|
|
260
|
-
tooltip.style.display = 'none'
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
} // there are no intersections
|
|
264
|
-
else {
|
|
265
|
-
// restore previous intersection object (if it exists) to its original color
|
|
266
|
-
// if ( this.INTERSECTED )
|
|
267
|
-
// this.INTERSECTED.material.color.setHex( this.INTERSECTED.currentHex );
|
|
268
|
-
// remove previous intersection object reference
|
|
269
|
-
// by setting current intersection object to "nothing"
|
|
270
|
-
this.INTERSECTED = null
|
|
271
|
-
|
|
272
|
-
tooltip.style.display = 'none'
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (this._keyboard.pressed('z')) {
|
|
276
|
-
// do something
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
this._controls.update()
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
render() {
|
|
283
|
-
this._renderer.render(this._scene, this._camera)
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
bindEvents() {
|
|
287
|
-
// when the mouse moves, call the given function
|
|
288
|
-
// this._container.addEventListener( 'mousedown', this.onMouseMove.bind(this), false );
|
|
289
|
-
this._container.addEventListener('mousemove', this.onMouseMove.bind(this), false)
|
|
290
|
-
// this.bindResize()
|
|
291
|
-
THREEx.FullScreen.bindKey({ charCode: 'm'.charCodeAt(0) })
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
onMouseDown(e) {
|
|
295
|
-
this._mouse.x = (e.offsetX / this.SCREEN_WIDTH) * 2 - 1
|
|
296
|
-
this._mouse.y = -(e.offsetY / this.SCREEN_HEIGHT) * 2 + 1
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
onMouseMove(e) {
|
|
300
|
-
// the following line would stop any other event handler from firing
|
|
301
|
-
// (such as the mouse's TrackballControls)
|
|
302
|
-
// event.preventDefault();
|
|
303
|
-
|
|
304
|
-
// update the mouse variable
|
|
305
|
-
this._mouse.x = (e.offsetX / this.SCREEN_WIDTH) * 2 - 1
|
|
306
|
-
this._mouse.y = -(e.offsetY / this.SCREEN_HEIGHT) * 2 + 1
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
bindResize() {
|
|
310
|
-
var renderer = this._renderer
|
|
311
|
-
var camera = this._camera
|
|
312
|
-
|
|
313
|
-
var callback = function() {
|
|
314
|
-
this.SCREEN_WIDTH = this._container.clientWidth
|
|
315
|
-
this.SCREEN_HEIGHT = this._container.clientHeight
|
|
316
|
-
|
|
317
|
-
// notify the renderer of the size change
|
|
318
|
-
// renderer.setSize( window.innerWidth, window.innerHeight );
|
|
319
|
-
renderer.setSize(this.SCREEN_WIDTH, this.SCREEN_HEIGHT)
|
|
320
|
-
renderer.setFaceCulling('front_and_back', 'cw')
|
|
321
|
-
// update the camera
|
|
322
|
-
camera.aspect = this.SCREEN_WIDTH / this.SCREEN_HEIGHT
|
|
323
|
-
camera.updateProjectionMatrix()
|
|
324
|
-
}
|
|
325
|
-
// bind the resize event
|
|
326
|
-
this._container.addEventListener('resize', callback.bind(this), false)
|
|
327
|
-
// return .stop() the function to stop watching window resize
|
|
328
|
-
return {
|
|
329
|
-
/**
|
|
330
|
-
* Stop watching window resize
|
|
331
|
-
*/
|
|
332
|
-
stop: function() {
|
|
333
|
-
this._container.removeEventListener('resize', callback)
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
run() {
|
|
339
|
-
this.animate()
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
stop() {
|
|
343
|
-
cancelAnimationFrame(this._animFrame)
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
rotateCam(angle) {
|
|
347
|
-
this._controls.rotateLeft(angle)
|
|
348
|
-
}
|
|
349
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import icon from '../assets/pallet-jockey.png'
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
type: 'pallet-jockey',
|
|
5
|
-
description: '3D pallet-jockey',
|
|
6
|
-
group: 'warehouse' /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */,
|
|
7
|
-
icon,
|
|
8
|
-
model: {
|
|
9
|
-
type: 'pallet-jockey',
|
|
10
|
-
left: 100,
|
|
11
|
-
top: 100,
|
|
12
|
-
width: 100,
|
|
13
|
-
height: 50,
|
|
14
|
-
depth: 50,
|
|
15
|
-
fillStyle: '#CCAA76',
|
|
16
|
-
strokeStyle: '#999',
|
|
17
|
-
lineWidth: 1,
|
|
18
|
-
alpha: 1
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import icon from '../assets/roller-conveyor.png'
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
type: 'roller-conveyor',
|
|
5
|
-
description: '3D roller-conveyor',
|
|
6
|
-
group: 'warehouse' /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */,
|
|
7
|
-
icon,
|
|
8
|
-
model: {
|
|
9
|
-
type: 'roller-conveyor',
|
|
10
|
-
left: 100,
|
|
11
|
-
top: 100,
|
|
12
|
-
width: 200,
|
|
13
|
-
height: 100,
|
|
14
|
-
depth: 100,
|
|
15
|
-
fillStyle: '#CCAA76',
|
|
16
|
-
strokeStyle: '#999',
|
|
17
|
-
lineWidth: 1,
|
|
18
|
-
alpha: 1
|
|
19
|
-
}
|
|
20
|
-
}
|