@babylonjs/core 8.4.0 → 8.4.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"observable.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/observable.ts"],"names":[],"mappings":"AAIA,MAAM,kBAAkB,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,UAAU;IACnB;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,iBAAiB,GAAG,KAAK,EAAE,MAAY,EAAE,aAAmB;QAClF,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;OAOG;IACI,UAAU,CAAC,IAAY,EAAE,iBAAiB,GAAG,KAAK,EAAE,MAAY,EAAE,aAAmB;QACxF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;CAgCJ;AAED;;GAEG;AACH,MAAM,OAAO,QAAQ;IAejB;;;;;OAKG;IACH;IACI;;OAEG;IACI,QAAwD;IAC/D;;OAEG;IACI,IAAY;IACnB;;OAEG;IACI,QAAa,IAAI;QARjB,aAAQ,GAAR,QAAQ,CAAgD;QAIxD,SAAI,GAAJ,IAAI,CAAQ;QAIZ,UAAK,GAAL,KAAK,CAAY;QAhC5B,gBAAgB;QACT,wBAAmB,GAAG,KAAK,CAAC;QACnC;;WAEG;QACI,yBAAoB,GAAG,KAAK,CAAC;QAEpC;;;;WAIG;QACI,YAAO,GAAyB,IAAI,CAAC;IAqBzC,CAAC;IAEJ;;;OAGG;IACI,MAAM;QACT,IAAI,IAAI,CAAC,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AAC;QAEnC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE7C,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;QAII;IACG,eAAe,CAAC,OAAe,CAAC,CAAC;QACpC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAChC,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACvC,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\n\r\ndeclare const WeakRef: any;\r\n\r\nconst isWeakRefSupported = typeof WeakRef !== \"undefined\";\r\n\r\n/**\r\n * A class serves as a medium between the observable and its observers\r\n */\r\nexport class EventState {\r\n /**\r\n * Create a new EventState\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n */\r\n constructor(mask: number, skipNextObservers = false, target?: any, currentTarget?: any) {\r\n this.initialize(mask, skipNextObservers, target, currentTarget);\r\n }\r\n\r\n /**\r\n * Initialize the current event state\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @returns the current event state\r\n */\r\n public initialize(mask: number, skipNextObservers = false, target?: any, currentTarget?: any): EventState {\r\n this.mask = mask;\r\n this.skipNextObservers = skipNextObservers;\r\n this.target = target;\r\n this.currentTarget = currentTarget;\r\n return this;\r\n }\r\n\r\n /**\r\n * An Observer can set this property to true to prevent subsequent observers of being notified\r\n */\r\n public skipNextObservers: boolean;\r\n\r\n /**\r\n * Get the mask value that were used to trigger the event corresponding to this EventState object\r\n */\r\n public mask: number;\r\n\r\n /**\r\n * The object that originally notified the event\r\n */\r\n public target?: any;\r\n\r\n /**\r\n * The current object in the bubbling phase\r\n */\r\n public currentTarget?: any;\r\n\r\n /**\r\n * This will be populated with the return value of the last function that was executed.\r\n * If it is the first function in the callback chain it will be the event data.\r\n */\r\n public lastReturnValue?: any;\r\n\r\n /**\r\n * User defined information that will be sent to observers\r\n */\r\n public userInfo?: any;\r\n}\r\n\r\n/**\r\n * Represent an Observer registered to a given Observable object.\r\n */\r\nexport class Observer<T> {\r\n /** @internal */\r\n public _willBeUnregistered = false;\r\n /**\r\n * Gets or sets a property defining that the observer as to be unregistered after the next notification\r\n */\r\n public unregisterOnNextCall = false;\r\n\r\n /**\r\n * this function can be used to remove the observer from the observable.\r\n * It will be set by the observable that the observer belongs to.\r\n * @internal\r\n */\r\n public _remove: Nullable<() => void> = null;\r\n\r\n /**\r\n * Creates a new observer\r\n * @param callback defines the callback to call when the observer is notified\r\n * @param mask defines the mask of the observer (used to filter notifications)\r\n * @param scope defines the current scope used to restore the JS context\r\n */\r\n constructor(\r\n /**\r\n * Defines the callback to call when the observer is notified\r\n */\r\n public callback: (eventData: T, eventState: EventState) => void,\r\n /**\r\n * Defines the mask of the observer (used to filter notifications)\r\n */\r\n public mask: number,\r\n /**\r\n * [null] Defines the current scope used to restore the JS context\r\n */\r\n public scope: any = null\r\n ) {}\r\n\r\n /**\r\n * Remove the observer from its observable\r\n * This can be used instead of using the observable's remove function.\r\n */\r\n public remove() {\r\n if (this._remove) {\r\n this._remove();\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * The Observable class is a simple implementation of the Observable pattern.\r\n *\r\n * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.\r\n * This enable a more fine grained execution without having to rely on multiple different Observable objects.\r\n * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).\r\n * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.\r\n */\r\nexport class Observable<T> {\r\n private _observers = new Array<Observer<T>>();\r\n private _numObserversMarkedAsDeleted = 0;\r\n private _hasNotified = false;\r\n private _lastNotifiedValue?: T;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _eventState: EventState;\r\n\r\n private _onObserverAdded: Nullable<(observer: Observer<T>) => void>;\r\n\r\n /**\r\n * Create an observable from a Promise.\r\n * @param promise a promise to observe for fulfillment.\r\n * @param onErrorObservable an observable to notify if a promise was rejected.\r\n * @returns the new Observable\r\n */\r\n public static FromPromise<T, E = Error>(promise: Promise<T>, onErrorObservable?: Observable<E>): Observable<T> {\r\n const observable = new Observable<T>();\r\n\r\n promise\r\n .then((ret: T) => {\r\n observable.notifyObservers(ret);\r\n })\r\n .catch((err) => {\r\n if (onErrorObservable) {\r\n onErrorObservable.notifyObservers(err as E);\r\n } else {\r\n throw err;\r\n }\r\n });\r\n\r\n return observable;\r\n }\r\n\r\n /**\r\n * Gets the list of observers\r\n * Note that observers that were recently deleted may still be present in the list because they are only really deleted on the next javascript tick!\r\n */\r\n public get observers(): Array<Observer<T>> {\r\n return this._observers;\r\n }\r\n\r\n /**\r\n * Creates a new observable\r\n * @param onObserverAdded defines a callback to call when a new observer is added\r\n * @param notifyIfTriggered If set to true the observable will notify when an observer was added if the observable was already triggered.\r\n */\r\n constructor(\r\n onObserverAdded?: (observer: Observer<T>) => void,\r\n /**\r\n * [false] If set to true the observable will notify when an observer was added if the observable was already triggered.\r\n * This is helpful to single-state observables like the scene onReady or the dispose observable.\r\n */\r\n public notifyIfTriggered = false\r\n ) {\r\n this._eventState = new EventState(0);\r\n\r\n if (onObserverAdded) {\r\n this._onObserverAdded = onObserverAdded;\r\n }\r\n }\r\n\r\n /**\r\n * Create a new Observer with the specified callback\r\n * @param callback the callback that will be executed for that Observer\r\n * @param mask the mask used to filter observers\r\n * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.\r\n * @param scope optional scope for the callback to be called from\r\n * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification\r\n * @returns the new observer created for the callback\r\n */\r\n public add(callback?: null | undefined, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): null;\r\n public add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Observer<T>;\r\n public add(\r\n callback?: ((eventData: T, eventState: EventState) => void) | null | undefined,\r\n mask?: number,\r\n insertFirst?: boolean,\r\n scope?: any,\r\n unregisterOnFirstCall?: boolean\r\n ): Nullable<Observer<T>>;\r\n public add(\r\n callback?: ((eventData: T, eventState: EventState) => void) | null | undefined,\r\n mask: number = -1,\r\n insertFirst = false,\r\n scope: any = null,\r\n unregisterOnFirstCall = false\r\n ): Nullable<Observer<T>> {\r\n if (!callback) {\r\n return null;\r\n }\r\n\r\n const observer = new Observer(callback, mask, scope);\r\n observer.unregisterOnNextCall = unregisterOnFirstCall;\r\n\r\n if (insertFirst) {\r\n this._observers.unshift(observer);\r\n } else {\r\n this._observers.push(observer);\r\n }\r\n\r\n if (this._onObserverAdded) {\r\n this._onObserverAdded(observer);\r\n }\r\n\r\n // If the observable was already triggered and the observable is set to notify if triggered, notify the new observer\r\n if (this._hasNotified && this.notifyIfTriggered) {\r\n if (this._lastNotifiedValue !== undefined) {\r\n this.notifyObserver(observer, this._lastNotifiedValue);\r\n }\r\n }\r\n\r\n // attach the remove function to the observer\r\n const observableWeakRef = isWeakRefSupported ? new WeakRef(this) : { deref: () => this };\r\n observer._remove = () => {\r\n const observable = observableWeakRef.deref();\r\n if (observable) {\r\n observable._remove(observer);\r\n }\r\n };\r\n\r\n return observer;\r\n }\r\n\r\n /**\r\n * Create a new Observer with the specified callback and unregisters after the next notification\r\n * @param callback the callback that will be executed for that Observer\r\n * @returns the new observer created for the callback\r\n */\r\n public addOnce(callback?: null | undefined): null;\r\n public addOnce(callback: (eventData: T, eventState: EventState) => void): Observer<T>;\r\n public addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null | undefined): Nullable<Observer<T>>;\r\n public addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null | undefined): Nullable<Observer<T>> {\r\n return this.add(callback, undefined, undefined, undefined, true);\r\n }\r\n\r\n /**\r\n * Remove an Observer from the Observable object\r\n * @param observer the instance of the Observer to remove\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n public remove(observer: Nullable<Observer<T>>): boolean {\r\n if (!observer) {\r\n return false;\r\n }\r\n\r\n observer._remove = null;\r\n const index = this._observers.indexOf(observer);\r\n\r\n if (index !== -1) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Remove a callback from the Observable object\r\n * @param callback the callback to remove\r\n * @param scope optional scope. If used only the callbacks with this scope will be removed\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n public removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean {\r\n for (let index = 0; index < this._observers.length; index++) {\r\n const observer = this._observers[index];\r\n if (observer._willBeUnregistered) {\r\n continue;\r\n }\r\n if (observer.callback === callback && (!scope || scope === observer.scope)) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _deferUnregister(observer: Observer<T>): void {\r\n if (observer._willBeUnregistered) {\r\n return;\r\n }\r\n this._numObserversMarkedAsDeleted++;\r\n observer.unregisterOnNextCall = false;\r\n observer._willBeUnregistered = true;\r\n setTimeout(() => {\r\n this._remove(observer);\r\n }, 0);\r\n }\r\n\r\n // This should only be called when not iterating over _observers to avoid callback skipping.\r\n // Removes an observer from the _observer Array.\r\n private _remove(observer: Nullable<Observer<T>>, updateCounter = true): boolean {\r\n if (!observer) {\r\n return false;\r\n }\r\n\r\n const index = this._observers.indexOf(observer);\r\n\r\n if (index !== -1) {\r\n if (updateCounter) {\r\n this._numObserversMarkedAsDeleted--;\r\n }\r\n this._observers.splice(index, 1);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Moves the observable to the top of the observer list making it get called first when notified\r\n * @param observer the observer to move\r\n */\r\n public makeObserverTopPriority(observer: Observer<T>) {\r\n this._remove(observer, false);\r\n this._observers.unshift(observer);\r\n }\r\n\r\n /**\r\n * Moves the observable to the bottom of the observer list making it get called last when notified\r\n * @param observer the observer to move\r\n */\r\n public makeObserverBottomPriority(observer: Observer<T>) {\r\n this._remove(observer, false);\r\n this._observers.push(observer);\r\n }\r\n\r\n /**\r\n * Notify all Observers by calling their respective callback with the given data\r\n * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute\r\n * @param eventData defines the data to send to all observers\r\n * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @param userInfo defines any user info to send to observers\r\n * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)\r\n */\r\n public notifyObservers(eventData: T, mask: number = -1, target?: any, currentTarget?: any, userInfo?: any): boolean {\r\n // this prevents potential memory leaks - if an object is disposed but the observable doesn't get cleared.\r\n if (this.notifyIfTriggered) {\r\n this._hasNotified = true;\r\n this._lastNotifiedValue = eventData;\r\n }\r\n if (!this._observers.length) {\r\n return true;\r\n }\r\n\r\n const state = this._eventState;\r\n state.mask = mask;\r\n state.target = target;\r\n state.currentTarget = currentTarget;\r\n state.skipNextObservers = false;\r\n state.lastReturnValue = eventData;\r\n state.userInfo = userInfo;\r\n\r\n for (const obs of this._observers) {\r\n if (obs._willBeUnregistered) {\r\n continue;\r\n }\r\n\r\n if (obs.mask & mask) {\r\n if (obs.unregisterOnNextCall) {\r\n this._deferUnregister(obs);\r\n }\r\n\r\n if (obs.scope) {\r\n state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);\r\n } else {\r\n state.lastReturnValue = obs.callback(eventData, state);\r\n }\r\n }\r\n if (state.skipNextObservers) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Notify a specific observer\r\n * @param observer defines the observer to notify\r\n * @param eventData defines the data to be sent to each callback\r\n * @param mask is used to filter observers defaults to -1\r\n */\r\n public notifyObserver(observer: Observer<T>, eventData: T, mask: number = -1): void {\r\n // this prevents potential memory leaks - if an object is disposed but the observable doesn't get cleared.\r\n if (this.notifyIfTriggered) {\r\n this._hasNotified = true;\r\n this._lastNotifiedValue = eventData;\r\n }\r\n if (observer._willBeUnregistered) {\r\n return;\r\n }\r\n\r\n const state = this._eventState;\r\n state.mask = mask;\r\n state.skipNextObservers = false;\r\n\r\n if (observer.unregisterOnNextCall) {\r\n this._deferUnregister(observer);\r\n }\r\n\r\n observer.callback(eventData, state);\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the observable has at least one observer\r\n * @returns true is the Observable has at least one Observer registered\r\n */\r\n public hasObservers(): boolean {\r\n return this._observers.length - this._numObserversMarkedAsDeleted > 0;\r\n }\r\n\r\n /**\r\n * Clear the list of observers\r\n */\r\n public clear(): void {\r\n while (this._observers.length) {\r\n const o = this._observers.pop();\r\n if (o) {\r\n o._remove = null;\r\n }\r\n }\r\n this._onObserverAdded = null;\r\n this._numObserversMarkedAsDeleted = 0;\r\n this.cleanLastNotifiedState();\r\n }\r\n\r\n /**\r\n * Clean the last notified state - both the internal last value and the has-notified flag\r\n */\r\n public cleanLastNotifiedState(): void {\r\n this._hasNotified = false;\r\n this._lastNotifiedValue = undefined;\r\n }\r\n\r\n /**\r\n * Clone the current observable\r\n * @returns a new observable\r\n */\r\n public clone(): Observable<T> {\r\n const result = new Observable<T>();\r\n\r\n result._observers = this._observers.slice(0);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Does this observable handles observer registered with a given mask\r\n * @param mask defines the mask to be tested\r\n * @returns whether or not one observer registered with the given mask is handled\r\n **/\r\n public hasSpecificMask(mask: number = -1): boolean {\r\n for (const obs of this._observers) {\r\n if (obs.mask & mask || obs.mask === mask) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"observable.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/observable.ts"],"names":[],"mappings":"AAIA,MAAM,kBAAkB,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,UAAU;IACnB;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,iBAAiB,GAAG,KAAK,EAAE,MAAY,EAAE,aAAmB;QAClF,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;OAOG;IACI,UAAU,CAAC,IAAY,EAAE,iBAAiB,GAAG,KAAK,EAAE,MAAY,EAAE,aAAmB;QACxF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;CAgCJ;AAED;;GAEG;AACH,MAAM,OAAO,QAAQ;IAejB;;;;;OAKG;IACH;IACI;;OAEG;IACI,QAAwD;IAC/D;;OAEG;IACI,IAAY;IACnB;;OAEG;IACI,QAAa,IAAI;QARjB,aAAQ,GAAR,QAAQ,CAAgD;QAIxD,SAAI,GAAJ,IAAI,CAAQ;QAIZ,UAAK,GAAL,KAAK,CAAY;QAhC5B,gBAAgB;QACT,wBAAmB,GAAG,KAAK,CAAC;QACnC;;WAEG;QACI,yBAAoB,GAAG,KAAK,CAAC;QAEpC;;;;WAIG;QACI,YAAO,GAAwC,IAAI,CAAC;IAqBxD,CAAC;IAEJ;;;;OAIG;IACI,MAAM,CAAC,KAAK,GAAG,KAAK;QACvB,I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K,CAAC;QAC1B,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,KAAK;QACR,MAAM,MAAM,GAAG,IAAI,UAAU,EAAK,CAAC;QAEnC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE7C,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;QAII;IACG,eAAe,CAAC,OAAe,CAAC,CAAC;QACpC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAChC,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACvC,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\n\r\ndeclare const WeakRef: any;\r\n\r\nconst isWeakRefSupported = typeof WeakRef !== \"undefined\";\r\n\r\n/**\r\n * A class serves as a medium between the observable and its observers\r\n */\r\nexport class EventState {\r\n /**\r\n * Create a new EventState\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n */\r\n constructor(mask: number, skipNextObservers = false, target?: any, currentTarget?: any) {\r\n this.initialize(mask, skipNextObservers, target, currentTarget);\r\n }\r\n\r\n /**\r\n * Initialize the current event state\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @returns the current event state\r\n */\r\n public initialize(mask: number, skipNextObservers = false, target?: any, currentTarget?: any): EventState {\r\n this.mask = mask;\r\n this.skipNextObservers = skipNextObservers;\r\n this.target = target;\r\n this.currentTarget = currentTarget;\r\n return this;\r\n }\r\n\r\n /**\r\n * An Observer can set this property to true to prevent subsequent observers of being notified\r\n */\r\n public skipNextObservers: boolean;\r\n\r\n /**\r\n * Get the mask value that were used to trigger the event corresponding to this EventState object\r\n */\r\n public mask: number;\r\n\r\n /**\r\n * The object that originally notified the event\r\n */\r\n public target?: any;\r\n\r\n /**\r\n * The current object in the bubbling phase\r\n */\r\n public currentTarget?: any;\r\n\r\n /**\r\n * This will be populated with the return value of the last function that was executed.\r\n * If it is the first function in the callback chain it will be the event data.\r\n */\r\n public lastReturnValue?: any;\r\n\r\n /**\r\n * User defined information that will be sent to observers\r\n */\r\n public userInfo?: any;\r\n}\r\n\r\n/**\r\n * Represent an Observer registered to a given Observable object.\r\n */\r\nexport class Observer<T> {\r\n /** @internal */\r\n public _willBeUnregistered = false;\r\n /**\r\n * Gets or sets a property defining that the observer as to be unregistered after the next notification\r\n */\r\n public unregisterOnNextCall = false;\r\n\r\n /**\r\n * this function can be used to remove the observer from the observable.\r\n * It will be set by the observable that the observer belongs to.\r\n * @internal\r\n */\r\n public _remove: Nullable<(defer?: boolean) => void> = null;\r\n\r\n /**\r\n * Creates a new observer\r\n * @param callback defines the callback to call when the observer is notified\r\n * @param mask defines the mask of the observer (used to filter notifications)\r\n * @param scope defines the current scope used to restore the JS context\r\n */\r\n constructor(\r\n /**\r\n * Defines the callback to call when the observer is notified\r\n */\r\n public callback: (eventData: T, eventState: EventState) => void,\r\n /**\r\n * Defines the mask of the observer (used to filter notifications)\r\n */\r\n public mask: number,\r\n /**\r\n * [null] Defines the current scope used to restore the JS context\r\n */\r\n public scope: any = null\r\n ) {}\r\n\r\n /**\r\n * Remove the observer from its observable\r\n * This can be used instead of using the observable's remove function.\r\n * @param defer if true, the removal will be deferred to avoid callback skipping (default: false)\r\n */\r\n public remove(defer = false) {\r\n if (this._remove) {\r\n this._remove(defer);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * The Observable class is a simple implementation of the Observable pattern.\r\n *\r\n * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.\r\n * This enable a more fine grained execution without having to rely on multiple different Observable objects.\r\n * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).\r\n * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.\r\n */\r\nexport class Observable<T> {\r\n private _observers = new Array<Observer<T>>();\r\n private _numObserversMarkedAsDeleted = 0;\r\n private _hasNotified = false;\r\n private _lastNotifiedValue?: T;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _eventState: EventState;\r\n\r\n private _onObserverAdded: Nullable<(observer: Observer<T>) => void>;\r\n\r\n /**\r\n * Create an observable from a Promise.\r\n * @param promise a promise to observe for fulfillment.\r\n * @param onErrorObservable an observable to notify if a promise was rejected.\r\n * @returns the new Observable\r\n */\r\n public static FromPromise<T, E = Error>(promise: Promise<T>, onErrorObservable?: Observable<E>): Observable<T> {\r\n const observable = new Observable<T>();\r\n\r\n promise\r\n .then((ret: T) => {\r\n observable.notifyObservers(ret);\r\n })\r\n .catch((err) => {\r\n if (onErrorObservable) {\r\n onErrorObservable.notifyObservers(err as E);\r\n } else {\r\n throw err;\r\n }\r\n });\r\n\r\n return observable;\r\n }\r\n\r\n /**\r\n * Gets the list of observers\r\n * Note that observers that were recently deleted may still be present in the list because they are only really deleted on the next javascript tick!\r\n */\r\n public get observers(): Array<Observer<T>> {\r\n return this._observers;\r\n }\r\n\r\n /**\r\n * Creates a new observable\r\n * @param onObserverAdded defines a callback to call when a new observer is added\r\n * @param notifyIfTriggered If set to true the observable will notify when an observer was added if the observable was already triggered.\r\n */\r\n constructor(\r\n onObserverAdded?: (observer: Observer<T>) => void,\r\n /**\r\n * [false] If set to true the observable will notify when an observer was added if the observable was already triggered.\r\n * This is helpful to single-state observables like the scene onReady or the dispose observable.\r\n */\r\n public notifyIfTriggered = false\r\n ) {\r\n this._eventState = new EventState(0);\r\n\r\n if (onObserverAdded) {\r\n this._onObserverAdded = onObserverAdded;\r\n }\r\n }\r\n\r\n /**\r\n * Create a new Observer with the specified callback\r\n * @param callback the callback that will be executed for that Observer\r\n * @param mask the mask used to filter observers\r\n * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.\r\n * @param scope optional scope for the callback to be called from\r\n * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification\r\n * @returns the new observer created for the callback\r\n */\r\n public add(callback?: null | undefined, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): null;\r\n public add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Observer<T>;\r\n public add(\r\n callback?: ((eventData: T, eventState: EventState) => void) | null | undefined,\r\n mask?: number,\r\n insertFirst?: boolean,\r\n scope?: any,\r\n unregisterOnFirstCall?: boolean\r\n ): Nullable<Observer<T>>;\r\n public add(\r\n callback?: ((eventData: T, eventState: EventState) => void) | null | undefined,\r\n mask: number = -1,\r\n insertFirst = false,\r\n scope: any = null,\r\n unregisterOnFirstCall = false\r\n ): Nullable<Observer<T>> {\r\n if (!callback) {\r\n return null;\r\n }\r\n\r\n const observer = new Observer(callback, mask, scope);\r\n observer.unregisterOnNextCall = unregisterOnFirstCall;\r\n\r\n if (insertFirst) {\r\n this._observers.unshift(observer);\r\n } else {\r\n this._observers.push(observer);\r\n }\r\n\r\n if (this._onObserverAdded) {\r\n this._onObserverAdded(observer);\r\n }\r\n\r\n // If the observable was already triggered and the observable is set to notify if triggered, notify the new observer\r\n if (this._hasNotified && this.notifyIfTriggered) {\r\n if (this._lastNotifiedValue !== undefined) {\r\n this.notifyObserver(observer, this._lastNotifiedValue);\r\n }\r\n }\r\n\r\n // attach the remove function to the observer\r\n const observableWeakRef = isWeakRefSupported ? new WeakRef(this) : { deref: () => this };\r\n observer._remove = (defer = false) => {\r\n const observable = observableWeakRef.deref();\r\n if (observable) {\r\n defer ? observable.remove(observer) : observable._remove(observer);\r\n }\r\n };\r\n\r\n return observer;\r\n }\r\n\r\n /**\r\n * Create a new Observer with the specified callback and unregisters after the next notification\r\n * @param callback the callback that will be executed for that Observer\r\n * @returns the new observer created for the callback\r\n */\r\n public addOnce(callback?: null | undefined): null;\r\n public addOnce(callback: (eventData: T, eventState: EventState) => void): Observer<T>;\r\n public addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null | undefined): Nullable<Observer<T>>;\r\n public addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null | undefined): Nullable<Observer<T>> {\r\n return this.add(callback, undefined, undefined, undefined, true);\r\n }\r\n\r\n /**\r\n * Remove an Observer from the Observable object\r\n * @param observer the instance of the Observer to remove\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n public remove(observer: Nullable<Observer<T>>): boolean {\r\n if (!observer) {\r\n return false;\r\n }\r\n\r\n observer._remove = null;\r\n const index = this._observers.indexOf(observer);\r\n\r\n if (index !== -1) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Remove a callback from the Observable object\r\n * @param callback the callback to remove\r\n * @param scope optional scope. If used only the callbacks with this scope will be removed\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n public removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean {\r\n for (let index = 0; index < this._observers.length; index++) {\r\n const observer = this._observers[index];\r\n if (observer._willBeUnregistered) {\r\n continue;\r\n }\r\n if (observer.callback === callback && (!scope || scope === observer.scope)) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _deferUnregister(observer: Observer<T>): void {\r\n if (observer._willBeUnregistered) {\r\n return;\r\n }\r\n this._numObserversMarkedAsDeleted++;\r\n observer.unregisterOnNextCall = false;\r\n observer._willBeUnregistered = true;\r\n setTimeout(() => {\r\n this._remove(observer);\r\n }, 0);\r\n }\r\n\r\n // This should only be called when not iterating over _observers to avoid callback skipping.\r\n // Removes an observer from the _observer Array.\r\n private _remove(observer: Nullable<Observer<T>>, updateCounter = true): boolean {\r\n if (!observer) {\r\n return false;\r\n }\r\n\r\n const index = this._observers.indexOf(observer);\r\n\r\n if (index !== -1) {\r\n if (updateCounter) {\r\n this._numObserversMarkedAsDeleted--;\r\n }\r\n this._observers.splice(index, 1);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Moves the observable to the top of the observer list making it get called first when notified\r\n * @param observer the observer to move\r\n */\r\n public makeObserverTopPriority(observer: Observer<T>) {\r\n this._remove(observer, false);\r\n this._observers.unshift(observer);\r\n }\r\n\r\n /**\r\n * Moves the observable to the bottom of the observer list making it get called last when notified\r\n * @param observer the observer to move\r\n */\r\n public makeObserverBottomPriority(observer: Observer<T>) {\r\n this._remove(observer, false);\r\n this._observers.push(observer);\r\n }\r\n\r\n /**\r\n * Notify all Observers by calling their respective callback with the given data\r\n * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute\r\n * @param eventData defines the data to send to all observers\r\n * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @param userInfo defines any user info to send to observers\r\n * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)\r\n */\r\n public notifyObservers(eventData: T, mask: number = -1, target?: any, currentTarget?: any, userInfo?: any): boolean {\r\n // this prevents potential memory leaks - if an object is disposed but the observable doesn't get cleared.\r\n if (this.notifyIfTriggered) {\r\n this._hasNotified = true;\r\n this._lastNotifiedValue = eventData;\r\n }\r\n if (!this._observers.length) {\r\n return true;\r\n }\r\n\r\n const state = this._eventState;\r\n state.mask = mask;\r\n state.target = target;\r\n state.currentTarget = currentTarget;\r\n state.skipNextObservers = false;\r\n state.lastReturnValue = eventData;\r\n state.userInfo = userInfo;\r\n\r\n for (const obs of this._observers) {\r\n if (obs._willBeUnregistered) {\r\n continue;\r\n }\r\n\r\n if (obs.mask & mask) {\r\n if (obs.unregisterOnNextCall) {\r\n this._deferUnregister(obs);\r\n }\r\n\r\n if (obs.scope) {\r\n state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);\r\n } else {\r\n state.lastReturnValue = obs.callback(eventData, state);\r\n }\r\n }\r\n if (state.skipNextObservers) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Notify a specific observer\r\n * @param observer defines the observer to notify\r\n * @param eventData defines the data to be sent to each callback\r\n * @param mask is used to filter observers defaults to -1\r\n */\r\n public notifyObserver(observer: Observer<T>, eventData: T, mask: number = -1): void {\r\n // this prevents potential memory leaks - if an object is disposed but the observable doesn't get cleared.\r\n if (this.notifyIfTriggered) {\r\n this._hasNotified = true;\r\n this._lastNotifiedValue = eventData;\r\n }\r\n if (observer._willBeUnregistered) {\r\n return;\r\n }\r\n\r\n const state = this._eventState;\r\n state.mask = mask;\r\n state.skipNextObservers = false;\r\n\r\n if (observer.unregisterOnNextCall) {\r\n this._deferUnregister(observer);\r\n }\r\n\r\n observer.callback(eventData, state);\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the observable has at least one observer\r\n * @returns true is the Observable has at least one Observer registered\r\n */\r\n public hasObservers(): boolean {\r\n return this._observers.length - this._numObserversMarkedAsDeleted > 0;\r\n }\r\n\r\n /**\r\n * Clear the list of observers\r\n */\r\n public clear(): void {\r\n while (this._observers.length) {\r\n const o = this._observers.pop();\r\n if (o) {\r\n o._remove = null;\r\n }\r\n }\r\n this._onObserverAdded = null;\r\n this._numObserversMarkedAsDeleted = 0;\r\n this.cleanLastNotifiedState();\r\n }\r\n\r\n /**\r\n * Clean the last notified state - both the internal last value and the has-notified flag\r\n */\r\n public cleanLastNotifiedState(): void {\r\n this._hasNotified = false;\r\n this._lastNotifiedValue = undefined;\r\n }\r\n\r\n /**\r\n * Clone the current observable\r\n * @returns a new observable\r\n */\r\n public clone(): Observable<T> {\r\n const result = new Observable<T>();\r\n\r\n result._observers = this._observers.slice(0);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Does this observable handles observer registered with a given mask\r\n * @param mask defines the mask to be tested\r\n * @returns whether or not one observer registered with the given mask is handled\r\n **/\r\n public hasSpecificMask(mask: number = -1): boolean {\r\n for (const obs of this._observers) {\r\n if (obs.mask & mask || obs.mask === mask) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\n"]}
@@ -33,7 +33,7 @@ varying vColor: vec4f;varying vPosition: vec2f;
33
33
  fn main(input : VertexInputs)->FragmentInputs {var splat: Splat=readSplat(input.splatIndex,uniforms.dataTextureSize);var covA: vec3f=splat.covA.xyz;var covB: vec3f=vec3f(splat.covA.w,splat.covB.xy);let worldPos: vec4f=mesh.world*vec4f(splat.center.xyz,1.0);vertexOutputs.vPosition=input.position;
34
34
  #if SH_DEGREE>0
35
35
  let worldRot: mat3x3f= mat3x3f(mesh.world[0].xyz,mesh.world[1].xyz,mesh.world[2].xyz);let normWorldRot: mat3x3f=inverseMat3(worldRot);var dir: vec3f=normalize(normWorldRot*(worldPos.xyz-scene.vEyePosition.xyz));dir*=vec3f(1.,1.,-1.);
36
- vertexOutputs.vColor=vec4f(computeSH(splat,splat.color.xyz,dir),1.0);
36
+ vertexOutputs.vColor=vec4f(computeSH(splat,splat.color.xyz,dir),splat.color.w);
37
37
  #else
38
38
  vertexOutputs.vColor=splat.color;
39
39
  #endif
@@ -1 +1 @@
1
- {"version":3,"file":"gaussianSplatting.vertex.js","sourceRoot":"","sources":["../../../../dev/core/src/ShadersWGSL/gaussianSplatting.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,6CAA6C,CAAC;AACrD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,oCAAoC,CAAC;AAC5C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,4BAA4B,CAAC;AACpC,OAAO,iCAAiC,CAAC;AAEzC,MAAM,IAAI,GAAG,+BAA+B,CAAC;AAC7C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Bd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/sceneUboDeclaration\";\nimport \"./ShadersInclude/meshUboDeclaration\";\nimport \"./ShadersInclude/helperFunctions\";\nimport \"./ShadersInclude/clipPlaneVertexDeclaration\";\nimport \"./ShadersInclude/fogVertexDeclaration\";\nimport \"./ShadersInclude/logDepthDeclaration\";\nimport \"./ShadersInclude/gaussianSplatting\";\nimport \"./ShadersInclude/clipPlaneVertex\";\nimport \"./ShadersInclude/fogVertex\";\nimport \"./ShadersInclude/logDepthVertex\";\n\nconst name = \"gaussianSplattingVertexShader\";\nconst shader = `#include<sceneUboDeclaration>\n#include<meshUboDeclaration>\n#include<helperFunctions>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<logDepthDeclaration>\nattribute splatIndex: f32;attribute position: vec2f;uniform invViewport: vec2f;uniform dataTextureSize: vec2f;uniform focal: vec2f;uniform kernelSize: f32;var covariancesATexture: texture_2d<f32>;var covariancesBTexture: texture_2d<f32>;var centersTexture: texture_2d<f32>;var colorsTexture: texture_2d<f32>;\n#if SH_DEGREE>0\nvar shTexture0: texture_2d<u32>;\n#endif\n#if SH_DEGREE>1\nvar shTexture1: texture_2d<u32>;\n#endif\n#if SH_DEGREE>2\nvar shTexture2: texture_2d<u32>;\n#endif\nvarying vColor: vec4f;varying vPosition: vec2f;\n#include<gaussianSplatting>\n@vertex\nfn main(input : VertexInputs)->FragmentInputs {var splat: Splat=readSplat(input.splatIndex,uniforms.dataTextureSize);var covA: vec3f=splat.covA.xyz;var covB: vec3f=vec3f(splat.covA.w,splat.covB.xy);let worldPos: vec4f=mesh.world*vec4f(splat.center.xyz,1.0);vertexOutputs.vPosition=input.position;\n#if SH_DEGREE>0\nlet worldRot: mat3x3f= mat3x3f(mesh.world[0].xyz,mesh.world[1].xyz,mesh.world[2].xyz);let normWorldRot: mat3x3f=inverseMat3(worldRot);var dir: vec3f=normalize(normWorldRot*(worldPos.xyz-scene.vEyePosition.xyz));dir*=vec3f(1.,1.,-1.); \nvertexOutputs.vColor=vec4f(computeSH(splat,splat.color.xyz,dir),1.0);\n#else\nvertexOutputs.vColor=splat.color;\n#endif\nvertexOutputs.position=gaussianSplatting(input.position,worldPos.xyz,vec2f(1.0,1.0),covA,covB,mesh.world,scene.view,scene.projection,uniforms.focal,uniforms.invViewport,uniforms.kernelSize);\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<logDepthVertex>\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const gaussianSplattingVertexShaderWGSL = { name, shader };\n"]}
1
+ {"version":3,"file":"gaussianSplatting.vertex.js","sourceRoot":"","sources":["../../../../dev/core/src/ShadersWGSL/gaussianSplatting.vertex.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,6CAA6C,CAAC;AACrD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,oCAAoC,CAAC;AAC5C,OAAO,kCAAkC,CAAC;AAC1C,OAAO,4BAA4B,CAAC;AACpC,OAAO,iCAAiC,CAAC;AAEzC,MAAM,IAAI,GAAG,+BAA+B,CAAC;AAC7C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Bd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/sceneUboDeclaration\";\nimport \"./ShadersInclude/meshUboDeclaration\";\nimport \"./ShadersInclude/helperFunctions\";\nimport \"./ShadersInclude/clipPlaneVertexDeclaration\";\nimport \"./ShadersInclude/fogVertexDeclaration\";\nimport \"./ShadersInclude/logDepthDeclaration\";\nimport \"./ShadersInclude/gaussianSplatting\";\nimport \"./ShadersInclude/clipPlaneVertex\";\nimport \"./ShadersInclude/fogVertex\";\nimport \"./ShadersInclude/logDepthVertex\";\n\nconst name = \"gaussianSplattingVertexShader\";\nconst shader = `#include<sceneUboDeclaration>\n#include<meshUboDeclaration>\n#include<helperFunctions>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<logDepthDeclaration>\nattribute splatIndex: f32;attribute position: vec2f;uniform invViewport: vec2f;uniform dataTextureSize: vec2f;uniform focal: vec2f;uniform kernelSize: f32;var covariancesATexture: texture_2d<f32>;var covariancesBTexture: texture_2d<f32>;var centersTexture: texture_2d<f32>;var colorsTexture: texture_2d<f32>;\n#if SH_DEGREE>0\nvar shTexture0: texture_2d<u32>;\n#endif\n#if SH_DEGREE>1\nvar shTexture1: texture_2d<u32>;\n#endif\n#if SH_DEGREE>2\nvar shTexture2: texture_2d<u32>;\n#endif\nvarying vColor: vec4f;varying vPosition: vec2f;\n#include<gaussianSplatting>\n@vertex\nfn main(input : VertexInputs)->FragmentInputs {var splat: Splat=readSplat(input.splatIndex,uniforms.dataTextureSize);var covA: vec3f=splat.covA.xyz;var covB: vec3f=vec3f(splat.covA.w,splat.covB.xy);let worldPos: vec4f=mesh.world*vec4f(splat.center.xyz,1.0);vertexOutputs.vPosition=input.position;\n#if SH_DEGREE>0\nlet worldRot: mat3x3f= mat3x3f(mesh.world[0].xyz,mesh.world[1].xyz,mesh.world[2].xyz);let normWorldRot: mat3x3f=inverseMat3(worldRot);var dir: vec3f=normalize(normWorldRot*(worldPos.xyz-scene.vEyePosition.xyz));dir*=vec3f(1.,1.,-1.); \nvertexOutputs.vColor=vec4f(computeSH(splat,splat.color.xyz,dir),splat.color.w);\n#else\nvertexOutputs.vColor=splat.color;\n#endif\nvertexOutputs.position=gaussianSplatting(input.position,worldPos.xyz,vec2f(1.0,1.0),covA,covB,mesh.world,scene.view,scene.projection,uniforms.focal,uniforms.invViewport,uniforms.kernelSize);\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<logDepthVertex>\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const gaussianSplattingVertexShaderWGSL = { name, shader };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/core",
3
- "version": "8.4.0",
3
+ "version": "8.4.1",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",