Просмотр исходного кода

removing duplication in shadow component

Justin Gilman 1 год назад
Родитель
Сommit
51c6c4ca2b

+ 5 - 4
Assets/Components/MobileDirectionalLight.re.ts

@@ -12,17 +12,18 @@ export default class MobileDirectionalLight extends RE.Component {
     const directionalLight: THREE.DirectionalLight = this.object3d as THREE.DirectionalLight
     this.initialOffset = this.object3d.position.clone()
     this.initialOffset.sub(new THREE.Vector3(0, 0, 0))
-    const offset: THREE.Vector3 = this.initialOffset.clone().add(this.target.position)
-    directionalLight.position.set(offset.x, offset.y, offset.z)
-    directionalLight.shadow.camera.position.set(offset.x, offset.y, offset.z)
+    this.updatePositions()
     directionalLight.target = this.target
   }
 
   update() {
+    this.updatePositions()
+  }
+
+  updatePositions() {
     const directionalLight: THREE.DirectionalLight = this.object3d as THREE.DirectionalLight
     const offset: THREE.Vector3 = this.initialOffset.clone().add(this.target.position)
     directionalLight.position.set(offset.x, offset.y, offset.z)
-
     directionalLight.shadow.camera.position.set(offset.x, offset.y, offset.z)
   }
 }

+ 4 - 3
dist/rogue-engine-user-scripts.js

@@ -867,12 +867,13 @@ class MobileDirectionalLight extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.C
     const directionalLight = this.object3d;
     this.initialOffset = this.object3d.position.clone();
     this.initialOffset.sub(new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0));
-    const offset = this.initialOffset.clone().add(this.target.position);
-    directionalLight.position.set(offset.x, offset.y, offset.z);
-    directionalLight.shadow.camera.position.set(offset.x, offset.y, offset.z);
+    this.updatePositions();
     directionalLight.target = this.target;
   }
   update() {
+    this.updatePositions();
+  }
+  updatePositions() {
     const directionalLight = this.object3d;
     const offset = this.initialOffset.clone().add(this.target.position);
     directionalLight.position.set(offset.x, offset.y, offset.z);

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
dist/rogue-engine-user-scripts.js.map


Некоторые файлы не были показаны из-за большого количества измененных файлов