浏览代码

tweaking lighting controls for camera shadow fix

Justin Gilman 1 年之前
父节点
当前提交
b290eee0f2

文件差异内容过多而无法显示
+ 0 - 0
Assets/Main.rogueScene


+ 3 - 3
Assets/rogue_packages/EyeOfMidas/directional-light-shadow-fix/DirectionalLightShadowFixForMobileCamera.re.ts

@@ -18,10 +18,10 @@ export default class DirectionalLightShadowFixForMobileCamera extends RE.Compone
 
   start() {
     const directionalLight: THREE.DirectionalLight = this.getDirectionalLight()
-    this.initialOffset.copy(directionalLight.position)
-    this.initialOffset.sub(new THREE.Vector3(0, 0, 0))
-    this.updatePositions()
+    this.initialOffset.copy(new THREE.Vector3(0, 0, 0))
+    this.initialOffset.add(directionalLight.position).normalize().multiplyScalar(100)
     directionalLight.target = this.getCamera()
+    this.updatePositions()
     if (directionalLight.shadow) {
       directionalLight.shadow.normalBias = 0.04;
     }

+ 6 - 34
dist/rogue-engine-user-scripts.js

@@ -127,23 +127,12 @@ __webpack_require__.r(__webpack_exports__);
 /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! three */ "three");
 /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(three__WEBPACK_IMPORTED_MODULE_1__);
 var __defProp = Object.defineProperty;
-var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
 var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
-var __decorateClass = (decorators, target, key, kind) => {
-  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
-  for (var i = decorators.length - 1, decorator; i >= 0; i--)
-    if (decorator = decorators[i])
-      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
-  if (kind && result)
-    __defProp(target, key, result);
-  return result;
-};
 
 
 class DirectionalLightShadowFixForMobileCamera extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
   constructor() {
     super(...arguments);
-    this.normalBias = 0.04;
     this.initialOffset = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
     this.currentOffset = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
   }
@@ -157,31 +146,20 @@ class DirectionalLightShadowFixForMobileCamera extends rogue_engine__WEBPACK_IMP
   }
   start() {
     const directionalLight = this.getDirectionalLight();
-    if (this.target) {
-      this.initialOffset.copy(directionalLight.position);
-      this.initialOffset.sub(new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0));
-      directionalLight.target = this.target;
-    } else {
-      this.initialOffset.copy(directionalLight.position);
-      this.initialOffset.sub(new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0));
-      directionalLight.target = this.getCamera();
-    }
+    this.initialOffset.copy(new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0));
+    this.initialOffset.add(directionalLight.position).normalize().multiplyScalar(100);
+    directionalLight.target = this.getCamera();
+    this.updatePositions();
     if (directionalLight.shadow) {
-      directionalLight.shadow.normalBias = this.normalBias;
+      directionalLight.shadow.normalBias = 0.04;
     }
-    rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Debug.log(`initial: ${this.initialOffset.x}, ${this.initialOffset.y}, ${this.initialOffset.z}`);
   }
   update() {
     this.updatePositions();
   }
   updatePositions() {
     const directionalLight = this.getDirectionalLight();
-    if (this.target) {
-      this.currentOffset.copy(this.target.position).add(this.initialOffset);
-    } else {
-      this.currentOffset.copy(this.getCamera().position).add(this.initialOffset);
-    }
-    rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Debug.log(`update: ${this.currentOffset.x}, ${this.currentOffset.y}, ${this.currentOffset.z}`);
+    this.currentOffset.copy(this.initialOffset).add(this.getCamera().position);
     directionalLight.position.set(this.currentOffset.x, this.currentOffset.y, this.currentOffset.z);
     if (directionalLight.shadow) {
       directionalLight.shadow.camera.position.set(this.currentOffset.x, this.currentOffset.y, this.currentOffset.z);
@@ -189,12 +167,6 @@ class DirectionalLightShadowFixForMobileCamera extends rogue_engine__WEBPACK_IMP
   }
 }
 __name(DirectionalLightShadowFixForMobileCamera, "DirectionalLightShadowFixForMobileCamera");
-__decorateClass([
-  rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
-], DirectionalLightShadowFixForMobileCamera.prototype, "normalBias", 2);
-__decorateClass([
-  rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.object3d()
-], DirectionalLightShadowFixForMobileCamera.prototype, "target", 2);
 rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(DirectionalLightShadowFixForMobileCamera);
 
 

文件差异内容过多而无法显示
+ 0 - 0
dist/rogue-engine-user-scripts.js.map


部分文件因为文件数量过多而无法显示