|
|
@@ -1,7 +1,14 @@
|
|
|
+import { UVMapping } from '../../constants.js';
|
|
|
+import { Euler } from '../../math/Euler.js';
|
|
|
+import { Matrix4 } from '../../math/Matrix4.js';
|
|
|
import Node from '../core/Node.js';
|
|
|
-import { nodeImmutable } from '../tsl/TSLBase.js';
|
|
|
+import { renderGroup } from '../core/UniformGroupNode.js';
|
|
|
+import { nodeImmutable, uniform } from '../tsl/TSLBase.js';
|
|
|
import { reference } from './ReferenceNode.js';
|
|
|
|
|
|
+const _e1 = /*@__PURE__*/ new Euler();
|
|
|
+const _m1 = /*@__PURE__*/ new Matrix4();
|
|
|
+
|
|
|
class SceneNode extends Node {
|
|
|
|
|
|
static get type() {
|
|
|
@@ -34,6 +41,31 @@ class SceneNode extends Node {
|
|
|
|
|
|
output = reference( 'backgroundIntensity', 'float', scene );
|
|
|
|
|
|
+ } else if ( scope === SceneNode.BACKGROUND_ROTATION ) {
|
|
|
+
|
|
|
+ output = uniform( 'mat4' ).label( 'backgroundRotation' ).setGroup( renderGroup ).onRenderUpdate( () => {
|
|
|
+
|
|
|
+ const background = scene.background;
|
|
|
+
|
|
|
+ if ( background !== null && background.isTexture && background.mapping !== UVMapping ) {
|
|
|
+
|
|
|
+ _e1.copy( scene.backgroundRotation );
|
|
|
+
|
|
|
+ // accommodate left-handed frame
|
|
|
+ _e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
|
|
|
+
|
|
|
+ _m1.makeRotationFromEuler( _e1 );
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ _m1.identity();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return _m1;
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
} else {
|
|
|
|
|
|
console.error( 'THREE.SceneNode: Unknown scope:', scope );
|
|
|
@@ -48,8 +80,10 @@ class SceneNode extends Node {
|
|
|
|
|
|
SceneNode.BACKGROUND_BLURRINESS = 'backgroundBlurriness';
|
|
|
SceneNode.BACKGROUND_INTENSITY = 'backgroundIntensity';
|
|
|
+SceneNode.BACKGROUND_ROTATION = 'backgroundRotation';
|
|
|
|
|
|
export default SceneNode;
|
|
|
|
|
|
export const backgroundBlurriness = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_BLURRINESS );
|
|
|
export const backgroundIntensity = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_INTENSITY );
|
|
|
+export const backgroundRotation = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_ROTATION );
|