@vyr/three-remote 0.0.1 → 0.0.3

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 CHANGED
@@ -1,23 +1 @@
1
- {
2
- "name": "@vyr/three-remote",
3
- "version": "0.0.1",
4
- "description": "",
5
- "main": "./src/index.ts",
6
- "author": "",
7
- "sideEffects": true,
8
- "license": "MIT",
9
- "dependencies": {
10
- "@vyr/locale": "0.0.1",
11
- "@vyr/engine": "0.0.1",
12
- "@vyr/remote": "0.0.1",
13
- "@vyr/three": "0.0.1"
14
- },
15
- "files": [
16
- "package.json",
17
- "src/"
18
- ],
19
- "vyr": {
20
- "type": "remote",
21
- "order": 1000
22
- }
23
- }
1
+ {"name":"@vyr/three-remote","version":"0.0.3","description":"","main":"./src/index.ts","author":"","sideEffects":true,"license":"MIT","dependencies":{"@vyr/locale":"0.0.3","@vyr/engine":"0.0.3","@vyr/remote":"0.0.3","@vyr/three":"0.0.3"},"files":["package.json","src/"],"vyr":{"type":"remote","order":1000}}
@@ -1,11 +1,10 @@
1
1
  import { Descriptor, Graphics, Scriptable, ServiceDescriptor } from "@vyr/engine";
2
- import { TransformControllerChangeArgs, TransformControllerDescriptor } from '@vyr/three'
2
+ import { TransformControllerChangeArgs } from '@vyr/three'
3
3
  import { RemoteProcess, Job } from '@vyr/remote'
4
4
  import { cache } from "./Cache"
5
5
 
6
6
  class ChangeScriptable extends Scriptable {
7
-
8
- execute(descriptor: TransformControllerDescriptor, graphics: Graphics, args: TransformControllerChangeArgs) {
7
+ execute(graphics: Graphics, args: TransformControllerChangeArgs) {
9
8
  const process = RemoteProcess.get(graphics.engine)
10
9
  if (process === null) return
11
10
 
@@ -1,4 +1,4 @@
1
- import { Asset, Descriptor, DeserializationObject, HTMLDescriptor, NodeDescriptor, PrefabeDescriptor, ServiceDescriptor, ServiceSchedulerDescriptor, Unit, UpdateArgs, Vector3 as _V3 } from '@vyr/engine'
1
+ import { Asset, Descriptor, DeserializationObject, HTMLDescriptor, NodeDescriptor, PrefabeDescriptor, ServiceDescriptor, ServiceSchedulerDescriptor, Unit, Vector3 as _V3 } from '@vyr/engine'
2
2
  import { GeometryDescriptor, MaterialDescriptor, MeshDescriptor, NodeActor, OrbitControllerActor, OrbitControllerDescriptor, ParticleDescriptor, PerspectiveCameraDescriptor, PointsDescriptor, PointsMaterialDescriptor, SceneServiceDescriptor, SpriteDescriptor, SpriteMaterialDescriptor, TextureDescriptor, TransformControllerDescriptor, THREE } from '@vyr/three'
3
3
  import { RemoteExecutor as _RemoteExecutor, Job, RemoteProcess } from '@vyr/remote'
4
4
  import { checkParentValidity, flyTo, getControllerByService, getGraphics, getTransformEvent, lookAt, resize, updateModelByScheduler, updateOtherUpdateJob } from './utils'
@@ -111,14 +111,13 @@ class RemoteExecutor extends _RemoteExecutor {
111
111
  if (descriptor instanceof PerspectiveCameraDescriptor) {
112
112
  const controller = getControllerByService(descriptor)
113
113
  if (controller === null || controller.orbit === null) return
114
- const args = { delta: 0 }
115
- const camera = graphics.getActor<NodeActor>(descriptor, args)
114
+ const camera = graphics.getActor<NodeActor>(descriptor)
116
115
  camera.object.updateMatrixWorld(true)
117
116
  const forward = camera.object.getWorldDirection(new THREE.Vector3())
118
117
  const lookAtPosition = new THREE.Vector3()
119
118
  .copy(camera.object.position)
120
119
  .add(forward.multiplyScalar(1)).negate()
121
- const orbitActor = graphics.getActor<OrbitControllerActor>(controller.orbit, args)
120
+ const orbitActor = graphics.getActor<OrbitControllerActor>(controller.orbit)
122
121
  orbitActor.controls.setLookAt(
123
122
  camera.object.position.x,
124
123
  camera.object.position.y,
@@ -260,7 +259,7 @@ class RemoteExecutor extends _RemoteExecutor {
260
259
  }
261
260
  }
262
261
  }
263
- onUpdateScheduler(unit: Unit, args: UpdateArgs) {
262
+ onUpdateScheduler(unit: Unit) {
264
263
  const descriptor = Descriptor.get<Descriptor>(unit.uuid)
265
264
  const service = cache.transformCollection.getByMap<TransformControllerDescriptor>(descriptor)
266
265
  ?? cache.orbitCollection.getByMap<OrbitControllerDescriptor>(descriptor)
@@ -270,12 +269,12 @@ class RemoteExecutor extends _RemoteExecutor {
270
269
  window['__VYR_RUNTIME.DISABLED_INPUT'] = false
271
270
  }
272
271
 
273
- super.onUpdateScheduler(unit, args)
272
+ super.onUpdateScheduler(unit)
274
273
  }
275
274
 
276
275
  enhance(process: RemoteProcess) {
277
- super.enhance(process, (scheduler) => {
278
- Object.defineProperty(scheduler, 'camera', { get() { return cache.camera.uuid }, set() { } })
276
+ super.enhance(process, (graphics) => {
277
+ Object.defineProperty(graphics.scheduler, 'camera', { get() { return cache.camera.uuid }, set() { } })
279
278
  })
280
279
  }
281
280
 
@@ -1,16 +1,16 @@
1
- import { CameraDescriptor, Graphics, Descriptor, NodeDescriptor, ServiceDescriptor, ServiceSchedulerDescriptor, UpdateArgs, Vector3 as _V3 } from "@vyr/engine"
1
+ import { CameraDescriptor, Graphics, Descriptor, NodeDescriptor, ServiceDescriptor, ServiceSchedulerDescriptor, Vector3 as _V3 } from "@vyr/engine"
2
2
  import { NodeActor, OrbitControllerActor, OrbitControllerDescriptor, TransformControllerDescriptor, THREE } from "@vyr/three"
3
3
  import { RemoteProcess } from "@vyr/remote"
4
4
  import { cache } from "../Cache"
5
5
 
6
6
  const rawVector3 = new THREE.Vector3(0, 0, 0)
7
7
  const emptyBox = new THREE.Box3()
8
- const getBox3 = (descriptor: Descriptor, graphics: Graphics, args: UpdateArgs) => {
8
+ const getBox3 = (descriptor: Descriptor, graphics: Graphics) => {
9
9
  const box3 = new THREE.Box3()
10
10
  // const ignore: Descriptor[] = []
11
11
  // if (instance) ignore.push(instance.orbit, instance.transform)
12
12
  descriptor.traverse(sub => {
13
- const actor = graphics.getActor<NodeActor<THREE.Object3D>>(sub, args)
13
+ const actor = graphics.getActor<NodeActor<THREE.Object3D>>(sub)
14
14
  if (actor instanceof NodeActor) {
15
15
  if (actor.object.visible === false) return true
16
16
  box3.expandByObject(actor.object)
@@ -28,13 +28,13 @@ const getControllerByService = (target: Descriptor) => {
28
28
  }
29
29
  return null
30
30
  }
31
- const getFlyInfo = (descriptor: Descriptor, graphics: Graphics, args: UpdateArgs) => {
32
- const box3 = getBox3(descriptor, graphics, args)
31
+ const getFlyInfo = (descriptor: Descriptor, graphics: Graphics) => {
32
+ const box3 = getBox3(descriptor, graphics)
33
33
 
34
34
  if (box3.equals(emptyBox)) return null
35
35
 
36
36
  const sphere = box3.getBoundingSphere(new THREE.Sphere())
37
- const cameraActor = graphics.getActor<NodeActor<THREE.PerspectiveCamera>>(cache.camera, args)
37
+ const cameraActor = graphics.getActor<NodeActor<THREE.PerspectiveCamera>>(cache.camera)
38
38
 
39
39
  const fov = THREE.MathUtils.degToRad(cameraActor.object.fov)
40
40
  const fovHorizontal = 2 * Math.atan(Math.tan(fov / 2) * cameraActor.object.aspect)
@@ -53,15 +53,15 @@ const getFlyInfo = (descriptor: Descriptor, graphics: Graphics, args: UpdateArgs
53
53
  lookAt: sphere.center
54
54
  }
55
55
  }
56
- const flyToTarget = (descriptor: Descriptor, graphics: Graphics, args: UpdateArgs, orbit: OrbitControllerDescriptor | null) => {
57
- const flyInfo = getFlyInfo(descriptor, graphics, args)
56
+ const flyToTarget = (descriptor: Descriptor, graphics: Graphics, orbit: OrbitControllerDescriptor | null) => {
57
+ const flyInfo = getFlyInfo(descriptor, graphics)
58
58
  if (flyInfo === null) return
59
59
 
60
60
  cache.camera.position.set(flyInfo.position.x, flyInfo.position.y, flyInfo.position.z)
61
61
  cache.camera.setNeedsUpdate()
62
62
  if (!orbit) return
63
63
 
64
- const orbitActor = graphics.getActor<OrbitControllerActor>(orbit, args)
64
+ const orbitActor = graphics.getActor<OrbitControllerActor>(orbit)
65
65
  orbitActor.controls.setLookAt(
66
66
  flyInfo.position.x,
67
67
  flyInfo.position.y,
@@ -85,17 +85,16 @@ const flyTo = (uuid: string, process: RemoteProcess) => {
85
85
  }
86
86
 
87
87
  const graphics = process.engine.getGraphics(process.scheduler)
88
- const args = { delta: 0 }
89
88
 
90
89
  if (services.length === 0) {
91
90
  const controller = getControllerByService(descriptor)
92
91
  if (controller === null) return
93
- flyToTarget(descriptor, graphics, args, controller.orbit)
92
+ flyToTarget(descriptor, graphics, controller.orbit)
94
93
  } else {
95
94
  for (const service of services) {
96
95
  const controller = getControllerByService(service)
97
96
  if (controller === null) return
98
- flyToTarget(descriptor, graphics, args, controller.orbit)
97
+ flyToTarget(descriptor, graphics, controller.orbit)
99
98
  }
100
99
  }
101
100
  }
@@ -58,7 +58,7 @@ const resize = (process: RemoteProcess) => {
58
58
  const graphics = process.engine.getGraphics(process.scheduler)
59
59
  if (graphics == null) return
60
60
  const interpreter = graphics.getInterpreter(cache.camera)
61
- const actor = interpreter.getActor<NodeActor<THREE.PerspectiveCamera>>(cache.camera, { delta: 0 })
61
+ const actor = interpreter.getActor<NodeActor<THREE.PerspectiveCamera>>(cache.camera)
62
62
  actor.object.aspect = process.engine.DOM.clientWidth / process.engine.DOM.clientHeight
63
63
  actor.object.updateProjectionMatrix()
64
64
  }
@@ -67,13 +67,12 @@ const resize = (process: RemoteProcess) => {
67
67
  const lookAt = (target: Descriptor, process: RemoteProcess) => {
68
68
  const controller = getControllerByService(target)
69
69
  if (controller === null) return
70
- const args = { delta: 0 }
71
70
  const graphics = process.engine.getGraphics(process.scheduler)
72
- const flyInfo = getFlyInfo(target, graphics, args)
71
+ const flyInfo = getFlyInfo(target, graphics)
73
72
  if (flyInfo === null) return
74
73
  if (!controller.orbit) return
75
74
 
76
- const orbitActor = graphics.getActor<OrbitControllerActor>(controller.orbit, args)
75
+ const orbitActor = graphics.getActor<OrbitControllerActor>(controller.orbit)
77
76
  orbitActor.controls.setTarget(
78
77
  flyInfo.lookAt.x,
79
78
  flyInfo.lookAt.y,
@@ -19,9 +19,8 @@ const updateAnimationAction = async (uuid: string, url: string, process: RemoteP
19
19
 
20
20
  const updateSceneService = (target: SceneServiceDescriptor, deserialization: DeserializationObject<SceneServiceDescriptor>, process: RemoteProcess) => {
21
21
  if (target.shadowMapType === deserialization.shadowMapType) return
22
- const args = { delta: 0 }
23
22
  const graphics = process.engine.getGraphics(process.scheduler)
24
- const actor = graphics.getActor<SceneServiceActor>(target, args)
23
+ const actor = graphics.getActor<SceneServiceActor>(target)
25
24
  if (actor === null) return
26
25
  actor.pipeline.resetState()
27
26
  actor.scene.traverse(sub => {
@@ -64,11 +63,10 @@ const updateModelByScheduler = (scheduler: ServiceSchedulerDescriptor, process:
64
63
 
65
64
  const updateTexture = (target: TextureDescriptor, deserialization: DeserializationObject<TextureDescriptor>, process: RemoteProcess) => {
66
65
  if (target.url === deserialization.url) return
67
- const args = { delta: 0 }
68
66
  const graphics = process.engine.getGraphics(process.scheduler)
69
67
  const unit = graphics.getUnit(target.uuid)
70
68
  if (unit === null) return
71
- graphics.doFree(unit, args)
69
+ graphics.doFree(unit)
72
70
  graphics.addRoot(unit.queue.url, target)
73
71
  observer.trigger('updateDeps', { self: target.uuid })
74
72
  }