Переглянути джерело

Fixes in decorators (calling onChange after function name minification).

master
Palash Bansal 1 рік тому
джерело
коміт
87a6825d5d
Аккаунт користувача з таким Email не знайдено

+ 4
- 4
package-lock.json Переглянути файл

@@ -13,7 +13,7 @@
"@types/webxr": "^0.5.1",
"@types/wicg-file-system-access": "^2020.9.5",
"stats.js": "^0.17.0",
"ts-browser-helpers": "^0.13.0",
"ts-browser-helpers": "^0.14.2",
"uiconfig.js": "^0.0.12"
},
"devDependencies": {
@@ -10564,9 +10564,9 @@
}
},
"node_modules/ts-browser-helpers": {
"version": "0.13.0",
"resolved": "https://registry.npmjs.org/ts-browser-helpers/-/ts-browser-helpers-0.13.0.tgz",
"integrity": "sha512-n0qO5+Nr9pngVechioLzWueQWqOItYhyu3O0cvFxz/lPt2M9zipqyFTLg5LdNA7NJnvHxv588eUZHmzmLcEa4Q==",
"version": "0.14.2",
"resolved": "https://registry.npmjs.org/ts-browser-helpers/-/ts-browser-helpers-0.14.2.tgz",
"integrity": "sha512-YAj98YRAl5uKWCBCh4pAHqJK/6tBcstIFa9Z9Q9SQTtzFSKKHo3TVHWdmC/fZxRIhuKthMmDHD5xb+qqb7a9xQ==",
"dependencies": {
"@types/wicg-file-system-access": "^2020.9.5"
}

+ 4
- 4
package.json Переглянути файл

@@ -15,7 +15,7 @@
"new:pack": "npm run prepare && clean-package && npm pack && clean-package restore",
"new:publish": "npm run prepare && clean-package && npm publish && clean-package restore",
"build:rollup": "rimraf dist && npm run update-version && NODE_ENV=production rollup -c",
"build": "npm run update-version && vite build",
"build": "npm run update-version && npm run compile && vite build",
"dev:rollup": "rollup -c -w",
"dev": "NODE_ENV=development vite build --watch",
"build-examples": "tsc --project examples/tsconfig.build.json",
@@ -26,7 +26,7 @@
"docs-plugins": "node scripts/each-plugin.mjs run docs",
"docs-all": "npm run docs && npm run docs-plugins",
"build-plugins": "node scripts/each-plugin.mjs install",
"prepare": "npm run build && npm run compile && npm run build-plugins && npm run build-examples",
"prepare": "npm run build && npm run build-plugins && npm run build-examples",
"update-version": "node scripts/update-version.mjs"
},
"clean-package": {
@@ -115,13 +115,13 @@
"@types/webxr": "^0.5.1",
"@types/wicg-file-system-access": "^2020.9.5",
"stats.js": "^0.17.0",
"ts-browser-helpers": "^0.13.0",
"ts-browser-helpers": "^0.14.2",
"uiconfig.js": "^0.0.12"
},
"//": {
"dependencies": {
"uiconfig.js": "^0.0.12",
"ts-browser-helpers": "^0.12.0",
"ts-browser-helpers": "^0.14.2",
"three": "https://github.com/repalash/three.js-modded/releases/download/v0.153.1003/package.tgz",
"three-f": "https://github.com/repalash/three.js-modded/archive/refs/tags/v0.153.1003.tar.gz",
"@types/three": "https://github.com/repalash/three-ts-types/releases/download/v0.153.1002/package.tgz",

+ 1
- 1
src/core/camera/PerspectiveCamera2.ts Переглянути файл

@@ -32,7 +32,7 @@ export class PerspectiveCamera2 extends PerspectiveCamera implements ICamera {
*/
private _canvas?: HTMLCanvasElement
get isMainCamera(): boolean {
return this.userData.__isMainCamera || false
return this.userData ? this.userData.__isMainCamera || false : false
}

@serialize()

+ 3
- 0
src/three/Threejs.ts Переглянути файл

@@ -215,6 +215,9 @@ export {ShapeUtils} from 'three'
export {PMREMGenerator} from 'three'
export {WebGLUtils} from 'three'

export type {ColorRepresentation, HSL, RGB} from 'three'
export type {ShaderMaterialParameters} from 'three'

export * from 'three/src/constants.js'

export type {Shader} from 'three'

+ 5
- 16
src/three/utils/decorators.ts Переглянути файл

@@ -1,4 +1,4 @@
import {AnyFunction, getOrCall, objectHasOwn, safeSetProperty, ValOrFunc} from 'ts-browser-helpers'
import {FnCaller, getOrCall, objectHasOwn, safeSetProperty, ValOrFunc} from 'ts-browser-helpers'

/**
*
@@ -34,7 +34,7 @@ export function uniform({uniforms, propKey, thisTarget = false, onChange}: {unif
if (val === newVal) return
u.value = newVal
safeSetProperty(this, 'uniformsNeedUpdate', true, true)
onChange && callOnChange.call(this, onChange, [propertyKey, newVal])
onChange && FnCaller.callFunction(onChange, this, [propertyKey, newVal])
},
// configurable: true,
// enumerable: true,
@@ -50,17 +50,6 @@ export function uniform({uniforms, propKey, thisTarget = false, onChange}: {unif
}
}

function callOnChange(this: any, onChange: (...args: any[]) => any, params: any[]) {
// same logic as onChange in ts-browser-helpers. todo: loop through object prototype chain like in onChange?
if (onChange.name) {
const fn: AnyFunction = this[onChange.name]
if (fn && fn === onChange)
onChange.call(this, ...params)
else if (fn && fn.name.endsWith(`bound ${onChange.name}`))
fn(...params)
else onChange(...params)
} else onChange(...params)
}
// todo migrate to new decorators - https://2ality.com/2022/10/javascript-decorators.html
/**
* Decorator to create a three.js style define in this.material or this and bind to a property.
@@ -101,7 +90,7 @@ export function matDefine(key?: string|symbol, customDefines?: any, thisMat = fa
safeSetProperty(t, p, newVal, true)
if (newVal === undefined) delete t[p]
if (onChange && typeof onChange === 'function') {
callOnChange.call(this, onChange, [p, newVal])
FnCaller.callFunction(onChange, this, [p, newVal])
} else {
safeSetProperty(thisMat ? this : this.material, 'needsUpdate', true, true)
}
@@ -165,8 +154,8 @@ export function bindToValue({obj, key, onChange, processVal, invProcessVal}: {ob
safeSetProperty(t, p, newVal, true)
if (newVal === undefined) delete t[p]
let oc = onChange
if (oc && (typeof oc === 'string' || typeof oc === 'symbol')) oc = this[oc]
if (oc && typeof oc === 'function') callOnChange.call(this, oc, [p, newVal])
if (oc && (typeof oc === 'string' || typeof oc === 'symbol')) oc = this[oc] // todo just call it here directly
if (oc && typeof oc === 'function') FnCaller.callFunction(oc, this, [p, newVal])
},
// configurable: true,
// enumerable: true,

+ 1
- 0
src/utils/browser-helpers.ts Переглянути файл

@@ -27,3 +27,4 @@ export {timeout, now} from 'ts-browser-helpers'
export {pathJoin, getUrlQueryParam, setUrlQueryParam, remoteWorkerURL} from 'ts-browser-helpers'
export {css, glsl, html, svgUrl} from 'ts-browser-helpers'
export {Serialization} from 'ts-browser-helpers'
export {FnCaller} from 'ts-browser-helpers'

Завантаження…
Відмінити
Зберегти