New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

super-three

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

super-three - npm Package Compare versions

Comparing version 0.164.0 to 0.165.0

examples/jsm/nodes/accessors/StorageTextureNode.js

2

examples/jsm/controls/TransformControls.js

@@ -35,3 +35,3 @@ import {

const _changeEvent = { type: 'change' };
const _mouseDownEvent = { type: 'mouseDown' };
const _mouseDownEvent = { type: 'mouseDown', mode: null };
const _mouseUpEvent = { type: 'mouseUp', mode: null };

@@ -38,0 +38,0 @@ const _objectChangeEvent = { type: 'objectChange' };

@@ -27,7 +27,3 @@ /**

let intensity = 5;
if ( renderer !== null && renderer._useLegacyLights === false ) intensity = 900;
const mainLight = new PointLight( 0xffffff, intensity, 28, 2 );
const mainLight = new PointLight( 0xffffff, 900, 28, 2 );
mainLight.position.set( 0.418, 16.199, 0.300 );

@@ -34,0 +30,0 @@ this.add( mainLight );

@@ -28,2 +28,3 @@ import {

},
includeAnchoringProperties: true,
quickLookCompatible: false,

@@ -202,2 +203,6 @@ maxTextureSize: 1024,

const alignment = options.includeAnchoringProperties === true ? `
token preliminary:anchoring:type = "${options.ar.anchoring.type}"
token preliminary:planeAnchoring:alignment = "${options.ar.planeAnchoring.alignment}"
` : '';
return `def Xform "Root"

@@ -216,6 +221,3 @@ {

)
{
token preliminary:anchoring:type = "${options.ar.anchoring.type}"
token preliminary:planeAnchoring:alignment = "${options.ar.planeAnchoring.alignment}"
{${alignment}
`;

@@ -222,0 +224,0 @@

import {
BoxGeometry,
CylinderGeometry,
CanvasTexture,

@@ -14,2 +14,3 @@ Color,

SpriteMaterial,
SRGBColorSpace,
Vector2,

@@ -31,5 +32,6 @@ Vector3,

const color1 = new Color( '#ff3653' );
const color2 = new Color( '#8adb00' );
const color3 = new Color( '#2c8fff' );
const color1 = new Color( '#ff4466' );
const color2 = new Color( '#88ff44' );
const color3 = new Color( '#4488ff' );
const color4 = new Color( '#000000' );

@@ -44,3 +46,3 @@ const interactiveObjects = [];

const geometry = new BoxGeometry( 0.8, 0.05, 0.05 ).translate( 0.4, 0, 0 );
const geometry = new CylinderGeometry( 0.04, 0.04, 0.8, 5 ).rotateZ( - Math.PI / 2 ).translate( 0.4, 0, 0 );

@@ -58,15 +60,14 @@ const xAxis = new Mesh( geometry, getAxisMaterial( color1 ) );

const posXAxisHelper = new Sprite( getSpriteMaterial( color1, 'X' ) );
posXAxisHelper.userData.type = 'posX';
const posYAxisHelper = new Sprite( getSpriteMaterial( color2, 'Y' ) );
posYAxisHelper.userData.type = 'posY';
const posZAxisHelper = new Sprite( getSpriteMaterial( color3, 'Z' ) );
posZAxisHelper.userData.type = 'posZ';
const negXAxisHelper = new Sprite( getSpriteMaterial( color1 ) );
negXAxisHelper.userData.type = 'negX';
const negYAxisHelper = new Sprite( getSpriteMaterial( color2 ) );
negYAxisHelper.userData.type = 'negY';
const negZAxisHelper = new Sprite( getSpriteMaterial( color3 ) );
negZAxisHelper.userData.type = 'negZ';
const spriteMaterial1 = getSpriteMaterial( color1 );
const spriteMaterial2 = getSpriteMaterial( color2 );
const spriteMaterial3 = getSpriteMaterial( color3 );
const spriteMaterial4 = getSpriteMaterial( color4 );
const posXAxisHelper = new Sprite( spriteMaterial1 );
const posYAxisHelper = new Sprite( spriteMaterial2 );
const posZAxisHelper = new Sprite( spriteMaterial3 );
const negXAxisHelper = new Sprite( spriteMaterial4 );
const negYAxisHelper = new Sprite( spriteMaterial4 );
const negZAxisHelper = new Sprite( spriteMaterial4 );
posXAxisHelper.position.x = 1;

@@ -76,8 +77,16 @@ posYAxisHelper.position.y = 1;

negXAxisHelper.position.x = - 1;
negXAxisHelper.scale.setScalar( 0.8 );
negYAxisHelper.position.y = - 1;
negYAxisHelper.scale.setScalar( 0.8 );
negZAxisHelper.position.z = - 1;
negZAxisHelper.scale.setScalar( 0.8 );
negXAxisHelper.material.opacity = 0.2;
negYAxisHelper.material.opacity = 0.2;
negZAxisHelper.material.opacity = 0.2;
posXAxisHelper.userData.type = 'posX';
posYAxisHelper.userData.type = 'posY';
posZAxisHelper.userData.type = 'posZ';
negXAxisHelper.userData.type = 'negX';
negYAxisHelper.userData.type = 'negY';
negZAxisHelper.userData.type = 'negZ';
this.add( posXAxisHelper );

@@ -109,38 +118,2 @@ this.add( posYAxisHelper );

if ( point.x >= 0 ) {
posXAxisHelper.material.opacity = 1;
negXAxisHelper.material.opacity = 0.5;
} else {
posXAxisHelper.material.opacity = 0.5;
negXAxisHelper.material.opacity = 1;
}
if ( point.y >= 0 ) {
posYAxisHelper.material.opacity = 1;
negYAxisHelper.material.opacity = 0.5;
} else {
posYAxisHelper.material.opacity = 0.5;
negYAxisHelper.material.opacity = 1;
}
if ( point.z >= 0 ) {
posZAxisHelper.material.opacity = 1;
negZAxisHelper.material.opacity = 0.5;
} else {
posZAxisHelper.material.opacity = 0.5;
negZAxisHelper.material.opacity = 1;
}
//

@@ -307,3 +280,3 @@

function getSpriteMaterial( color, text = null ) {
function getSpriteMaterial( color ) {

@@ -316,3 +289,3 @@ const canvas = document.createElement( 'canvas' );

context.beginPath();
context.arc( 32, 32, 16, 0, 2 * Math.PI );
context.arc( 32, 32, 14, 0, 2 * Math.PI );
context.closePath();

@@ -322,12 +295,4 @@ context.fillStyle = color.getStyle();

if ( text !== null ) {
context.font = '24px Arial';
context.textAlign = 'center';
context.fillStyle = '#000000';
context.fillText( text, 32, 41 );
}
const texture = new CanvasTexture( canvas );
texture.colorSpace = SRGBColorSpace;

@@ -334,0 +299,0 @@ return new SpriteMaterial( { map: texture, toneMapped: false } );

@@ -10,9 +10,9 @@ /**

In: function (amount) {
return this.None(amount);
return amount;
},
Out: function (amount) {
return this.None(amount);
return amount;
},
InOut: function (amount) {
return this.None(amount);
return amount;
},

@@ -680,3 +680,2 @@ }),

Tween.prototype.update = function (time, autoStart) {
var _this = this;
var _a;

@@ -687,3 +686,2 @@ if (time === void 0) { time = now(); }

return true;
var property;
var endTime = this._startTime + this._duration;

@@ -715,69 +713,82 @@ if (!this._goToEnd && !this._isPlaying) {

var totalTime = this._duration + this._repeat * durationAndDelay;
var calculateElapsedPortion = function () {
if (_this._duration === 0)
return 1;
if (elapsedTime > totalTime) {
return 1;
}
var timesRepeated = Math.trunc(elapsedTime / durationAndDelay);
var timeIntoCurrentRepeat = elapsedTime - timesRepeated * durationAndDelay;
// TODO use %?
// const timeIntoCurrentRepeat = elapsedTime % durationAndDelay
var portion = Math.min(timeIntoCurrentRepeat / _this._duration, 1);
if (portion === 0 && elapsedTime === _this._duration) {
return 1;
}
return portion;
};
var elapsed = calculateElapsedPortion();
var elapsed = this._calculateElapsedPortion(elapsedTime, durationAndDelay, totalTime);
var value = this._easingFunction(elapsed);
// properties transformations
var status = this._calculateCompletionStatus(elapsedTime, durationAndDelay);
if (status === 'repeat') {
// the current update is happening after the instant the tween repeated
this._processRepetition(elapsedTime, durationAndDelay);
}
this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
if (status === 'about-to-repeat') {
// the current update is happening at the exact instant the tween is going to repeat
// the values should match the end of the tween, not the beginning,
// that's why _processRepetition happens after _updateProperties
this._processRepetition(elapsedTime, durationAndDelay);
}
if (this._onUpdateCallback) {
this._onUpdateCallback(this._object, elapsed);
}
if (this._duration === 0 || elapsedTime >= this._duration) {
if (this._repeat > 0) {
var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat);
if (isFinite(this._repeat)) {
this._repeat -= completeCount;
}
// Reassign starting values, restart by making startTime = now
for (property in this._valuesStartRepeat) {
if (!this._yoyo && typeof this._valuesEnd[property] === 'string') {
this._valuesStartRepeat[property] =
// eslint-disable-next-line
// @ts-ignore FIXME?
this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
}
if (this._yoyo) {
this._swapEndStartRepeatValues(property);
}
this._valuesStart[property] = this._valuesStartRepeat[property];
}
if (this._yoyo) {
this._reversed = !this._reversed;
}
this._startTime += durationAndDelay * completeCount;
if (this._onRepeatCallback) {
this._onRepeatCallback(this._object);
}
this._onEveryStartCallbackFired = false;
return true;
if (status === 'repeat' || status === 'about-to-repeat') {
if (this._onRepeatCallback) {
this._onRepeatCallback(this._object);
}
else {
if (this._onCompleteCallback) {
this._onCompleteCallback(this._object);
}
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
// Make the chained tweens start exactly at the time they should,
// even if the `update()` method was called way past the duration of the tween
this._chainedTweens[i].start(this._startTime + this._duration, false);
}
this._isPlaying = false;
return false;
this._onEveryStartCallbackFired = false;
}
else if (status === 'completed') {
this._isPlaying = false;
if (this._onCompleteCallback) {
this._onCompleteCallback(this._object);
}
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
// Make the chained tweens start exactly at the time they should,
// even if the `update()` method was called way past the duration of the tween
this._chainedTweens[i].start(this._startTime + this._duration, false);
}
}
return true;
return status !== 'completed';
};
Tween.prototype._calculateElapsedPortion = function (elapsedTime, durationAndDelay, totalTime) {
if (this._duration === 0 || elapsedTime > totalTime) {
return 1;
}
var timeIntoCurrentRepeat = elapsedTime % durationAndDelay;
var portion = Math.min(timeIntoCurrentRepeat / this._duration, 1);
if (portion === 0 && elapsedTime !== 0 && elapsedTime % this._duration === 0) {
return 1;
}
return portion;
};
Tween.prototype._calculateCompletionStatus = function (elapsedTime, durationAndDelay) {
if (this._duration !== 0 && elapsedTime < this._duration) {
return 'playing';
}
if (this._repeat <= 0) {
return 'completed';
}
if (elapsedTime === this._duration) {
return 'about-to-repeat';
}
return 'repeat';
};
Tween.prototype._processRepetition = function (elapsedTime, durationAndDelay) {
var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat);
if (isFinite(this._repeat)) {
this._repeat -= completeCount;
}
// Reassign starting values, restart by making startTime = now
for (var property in this._valuesStartRepeat) {
var valueEnd = this._valuesEnd[property];
if (!this._yoyo && typeof valueEnd === 'string') {
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(valueEnd);
}
if (this._yoyo) {
this._swapEndStartRepeatValues(property);
}
this._valuesStart[property] = this._valuesStartRepeat[property];
}
if (this._yoyo) {
this._reversed = !this._reversed;
}
this._startTime += durationAndDelay * completeCount;
};
Tween.prototype._updateProperties = function (_object, _valuesStart, _valuesEnd, value) {

@@ -837,3 +848,3 @@ for (var property in _valuesEnd) {

var VERSION = '23.1.1';
var VERSION = '23.1.2';

@@ -840,0 +851,0 @@ /**

@@ -1,14 +0,1 @@

/**
* parameters = {
* color: <hex>,
* linewidth: <float>,
* dashed: <boolean>,
* dashScale: <float>,
* dashSize: <float>,
* dashOffset: <float>,
* gapSize: <float>,
* resolution: <Vector2>, // to be set by renderer
* }
*/
import {

@@ -19,6 +6,5 @@ ShaderLib,

UniformsUtils,
Vector2
Vector2,
} from 'three';
UniformsLib.line = {

@@ -25,0 +11,0 @@

@@ -16,2 +16,4 @@ import {

const _viewport = new Vector4();
const _start = new Vector3();

@@ -360,4 +362,17 @@ const _end = new Vector3();

onBeforeRender( renderer ) {
const uniforms = this.material.uniforms;
if ( uniforms && uniforms.resolution ) {
renderer.getViewport( _viewport );
this.material.uniforms.resolution.value.set( _viewport.z, _viewport.w );
}
}
}
export { LineSegments2 };

@@ -5,3 +5,4 @@ import {

Mesh,
Vector3
Vector3,
Vector4
} from 'three';

@@ -13,2 +14,3 @@ import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';

const _end = new Vector3();
const _viewport = new Vector4();

@@ -56,4 +58,17 @@ class Wireframe extends Mesh {

onBeforeRender( renderer ) {
const uniforms = this.material.uniforms;
if ( uniforms && uniforms.resolution ) {
renderer.getViewport( _viewport );
this.material.uniforms.resolution.value.set( _viewport.z, _viewport.w );
}
}
}
export { Wireframe };

@@ -88,3 +88,3 @@ import {

this.decodeDracoFile( buffer, onLoad, null, null, SRGBColorSpace ).catch( onError );
this.decodeDracoFile( buffer, onLoad, null, null, SRGBColorSpace, onError ).catch( onError );

@@ -91,0 +91,0 @@ }

@@ -1977,3 +1977,3 @@ import {

parse( text, onLoad ) {
parse( text, onLoad, onError ) {

@@ -1989,3 +1989,4 @@ this.partsCache

} );
} )
.catch( onError );

@@ -1992,0 +1993,0 @@ }

@@ -134,19 +134,37 @@ import {

const modelExtension = this._extractExtension( url ).toLowerCase();
const parser = this._getParser();
const extractModelExtension = this._extractModelExtension;
// Should I detect by seeing header?
if ( modelExtension !== 'pmd' && modelExtension !== 'pmx' ) {
this.loader
.setMimeType( undefined )
.setPath( this.path )
.setResponseType( 'arraybuffer' )
.setRequestHeader( this.requestHeader )
.setWithCredentials( this.withCredentials )
.load( url, function ( buffer ) {
if ( onError ) onError( new Error( 'THREE.MMDLoader: Unknown model file extension .' + modelExtension + '.' ) );
try {
return;
const modelExtension = extractModelExtension( buffer );
}
if ( modelExtension !== 'pmd' && modelExtension !== 'pmx' ) {
this[ modelExtension === 'pmd' ? 'loadPMD' : 'loadPMX' ]( url, function ( data ) {
if ( onError ) onError( new Error( 'THREE.MMDLoader: Unknown model file extension .' + modelExtension + '.' ) );
onLoad( builder.build( data, resourcePath, onProgress, onError ) );
return;
}, onProgress, onError );
}
const data = modelExtension === 'pmd' ? parser.parsePmd( buffer, true ) : parser.parsePmx( buffer, true );
onLoad( builder.build( data, resourcePath, onProgress, onError ) );
} catch ( e ) {
if ( onError ) onError( e );
}
}, onProgress, onError );
}

@@ -362,6 +380,7 @@

_extractExtension( url ) {
_extractModelExtension( buffer ) {
const index = url.lastIndexOf( '.' );
return index < 0 ? '' : url.slice( index + 1 );
const decoder = new TextDecoder( 'utf-8' );
const bytes = new Uint8Array( buffer, 0, 3 );
return decoder.decode( bytes ).toLowerCase();

@@ -368,0 +387,0 @@ }

@@ -8,8 +8,9 @@ // Original src: https://github.com/zz85/threejs-path-flow

DataTexture,
DataUtils,
RGBAFormat,
FloatType,
HalfFloatType,
RepeatWrapping,
Mesh,
InstancedMesh,
NearestFilter,
LinearFilter,
DynamicDrawUsage,

@@ -26,3 +27,3 @@ Matrix4

const dataArray = new Float32Array( TEXTURE_WIDTH * TEXTURE_HEIGHT * numberOfCurves * CHANNELS );
const dataArray = new Uint16Array( TEXTURE_WIDTH * TEXTURE_HEIGHT * numberOfCurves * CHANNELS );
const dataTexture = new DataTexture(

@@ -33,3 +34,3 @@ dataArray,

RGBAFormat,
FloatType
HalfFloatType
);

@@ -39,3 +40,4 @@

dataTexture.wrapY = RepeatWrapping;
dataTexture.magFilter = NearestFilter;
dataTexture.magFilter = LinearFilter;
dataTexture.minFilter = LinearFilter;
dataTexture.needsUpdate = true;

@@ -88,6 +90,6 @@

const i = CHANNELS * TEXTURE_WIDTH * o; // Row Offset
data[ index * CHANNELS + i + 0 ] = x;
data[ index * CHANNELS + i + 1 ] = y;
data[ index * CHANNELS + i + 2 ] = z;
data[ index * CHANNELS + i + 3 ] = 1;
data[ index * CHANNELS + i + 0 ] = DataUtils.toHalfFloat( x );
data[ index * CHANNELS + i + 1 ] = DataUtils.toHalfFloat( y );
data[ index * CHANNELS + i + 2 ] = DataUtils.toHalfFloat( z );
data[ index * CHANNELS + i + 3 ] = DataUtils.toHalfFloat( 1 );

@@ -94,0 +96,0 @@ }

@@ -1,89 +0,13 @@

import Node, { addNodeClass } from '../core/Node.js';
import { varying } from '../core/VaryingNode.js';
import { normalize } from '../math/MathNode.js';
import { cameraViewMatrix } from './CameraNode.js';
import { normalGeometry, normalLocal, normalView, normalWorld, transformedNormalView } from './NormalNode.js';
import { tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView } from './TangentNode.js';
import { nodeImmutable } from '../shadernode/ShaderNode.js';
class BitangentNode extends Node {
const getBitangent = ( crossNormalTangent ) => crossNormalTangent.mul( tangentGeometry.w ).xyz;
constructor( scope = BitangentNode.LOCAL ) {
super( 'vec3' );
this.scope = scope;
}
getHash( /*builder*/ ) {
return `bitangent-${this.scope}`;
}
generate( builder ) {
const scope = this.scope;
let crossNormalTangent;
if ( scope === BitangentNode.GEOMETRY ) {
crossNormalTangent = normalGeometry.cross( tangentGeometry );
} else if ( scope === BitangentNode.LOCAL ) {
crossNormalTangent = normalLocal.cross( tangentLocal );
} else if ( scope === BitangentNode.VIEW ) {
crossNormalTangent = normalView.cross( tangentView );
} else if ( scope === BitangentNode.WORLD ) {
crossNormalTangent = normalWorld.cross( tangentWorld );
}
const vertexNode = crossNormalTangent.mul( tangentGeometry.w ).xyz;
const outputNode = normalize( varying( vertexNode ) );
return outputNode.build( builder, this.getNodeType( builder ) );
}
serialize( data ) {
super.serialize( data );
data.scope = this.scope;
}
deserialize( data ) {
super.deserialize( data );
this.scope = data.scope;
}
}
BitangentNode.GEOMETRY = 'geometry';
BitangentNode.LOCAL = 'local';
BitangentNode.VIEW = 'view';
BitangentNode.WORLD = 'world';
export default BitangentNode;
export const bitangentGeometry = nodeImmutable( BitangentNode, BitangentNode.GEOMETRY );
export const bitangentLocal = nodeImmutable( BitangentNode, BitangentNode.LOCAL );
export const bitangentView = nodeImmutable( BitangentNode, BitangentNode.VIEW );
export const bitangentWorld = nodeImmutable( BitangentNode, BitangentNode.WORLD );
export const transformedBitangentView = normalize( transformedNormalView.cross( transformedTangentView ).mul( tangentGeometry.w ) );
export const transformedBitangentWorld = normalize( transformedBitangentView.transformDirection( cameraViewMatrix ) );
addNodeClass( 'BitangentNode', BitangentNode );
export const bitangentGeometry = /*#__PURE__*/ varying( getBitangent( normalGeometry.cross( tangentGeometry ) ), 'v_bitangentGeometry' ).normalize().toVar( 'bitangentGeometry' );
export const bitangentLocal = /*#__PURE__*/ varying( getBitangent( normalLocal.cross( tangentLocal ) ), 'v_bitangentLocal' ).normalize().toVar( 'bitangentLocal' );
export const bitangentView = /*#__PURE__*/ varying( getBitangent( normalView.cross( tangentView ) ), 'v_bitangentView' ).normalize().toVar( 'bitangentView' );
export const bitangentWorld = /*#__PURE__*/ varying( getBitangent( normalWorld.cross( tangentWorld ) ), 'v_bitangentWorld' ).normalize().toVar( 'bitangentWorld' );
export const transformedBitangentView = /*#__PURE__*/ getBitangent( transformedNormalView.cross( transformedTangentView ) ).normalize().toVar( 'transformedBitangentView' );
export const transformedBitangentWorld = /*#__PURE__*/ transformedBitangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedBitangentWorld' );

@@ -18,2 +18,8 @@ import UniformNode from '../core/UniformNode.js';

getElementType( builder ) {
return this.getNodeType( builder );
}
getInputType( /*builder*/ ) {

@@ -20,0 +26,0 @@

@@ -1,119 +0,12 @@

import Object3DNode from './Object3DNode.js';
import { addNodeClass } from '../core/Node.js';
import { NodeUpdateType } from '../core/constants.js';
//import { sharedUniformGroup } from '../core/UniformGroupNode.js';
import { nodeImmutable } from '../shadernode/ShaderNode.js';
import { uniform } from '../core/UniformNode.js';
import { Vector3 } from 'three';
//const cameraGroup = sharedUniformGroup( 'camera' );
class CameraNode extends Object3DNode {
constructor( scope = CameraNode.POSITION ) {
super( scope );
this.updateType = NodeUpdateType.RENDER;
//this._uniformNode.groupNode = cameraGroup;
}
getNodeType( builder ) {
const scope = this.scope;
if ( scope === CameraNode.PROJECTION_MATRIX || scope === CameraNode.PROJECTION_MATRIX_INVERSE ) {
return 'mat4';
} else if ( scope === CameraNode.NEAR || scope === CameraNode.FAR || scope === CameraNode.LOG_DEPTH ) {
return 'float';
}
return super.getNodeType( builder );
}
update( frame ) {
const camera = frame.camera;
const uniformNode = this._uniformNode;
const scope = this.scope;
//cameraGroup.needsUpdate = true;
if ( scope === CameraNode.VIEW_MATRIX ) {
uniformNode.value = camera.matrixWorldInverse;
} else if ( scope === CameraNode.PROJECTION_MATRIX ) {
uniformNode.value = camera.projectionMatrix;
} else if ( scope === CameraNode.PROJECTION_MATRIX_INVERSE ) {
uniformNode.value = camera.projectionMatrixInverse;
} else if ( scope === CameraNode.NEAR ) {
uniformNode.value = camera.near;
} else if ( scope === CameraNode.FAR ) {
uniformNode.value = camera.far;
} else if ( scope === CameraNode.LOG_DEPTH ) {
uniformNode.value = 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 );
} else {
this.object3d = camera;
super.update( frame );
}
}
generate( builder ) {
const scope = this.scope;
if ( scope === CameraNode.PROJECTION_MATRIX || scope === CameraNode.PROJECTION_MATRIX_INVERSE ) {
this._uniformNode.nodeType = 'mat4';
} else if ( scope === CameraNode.NEAR || scope === CameraNode.FAR || scope === CameraNode.LOG_DEPTH ) {
this._uniformNode.nodeType = 'float';
}
return super.generate( builder );
}
}
CameraNode.PROJECTION_MATRIX = 'projectionMatrix';
CameraNode.PROJECTION_MATRIX_INVERSE = 'projectionMatrixInverse';
CameraNode.NEAR = 'near';
CameraNode.FAR = 'far';
CameraNode.LOG_DEPTH = 'logDepth';
export default CameraNode;
export const cameraProjectionMatrix = nodeImmutable( CameraNode, CameraNode.PROJECTION_MATRIX );
export const cameraProjectionMatrixInverse = nodeImmutable( CameraNode, CameraNode.PROJECTION_MATRIX_INVERSE );
export const cameraNear = nodeImmutable( CameraNode, CameraNode.NEAR );
export const cameraFar = nodeImmutable( CameraNode, CameraNode.FAR );
export const cameraLogDepth = nodeImmutable( CameraNode, CameraNode.LOG_DEPTH );
export const cameraViewMatrix = nodeImmutable( CameraNode, CameraNode.VIEW_MATRIX );
export const cameraNormalMatrix = nodeImmutable( CameraNode, CameraNode.NORMAL_MATRIX );
export const cameraWorldMatrix = nodeImmutable( CameraNode, CameraNode.WORLD_MATRIX );
export const cameraPosition = nodeImmutable( CameraNode, CameraNode.POSITION );
addNodeClass( 'CameraNode', CameraNode );
export const cameraNear = /*#__PURE__*/ uniform( 'float' ).onRenderUpdate( ( { camera } ) => camera.near );
export const cameraFar = /*#__PURE__*/ uniform( 'float' ).onRenderUpdate( ( { camera } ) => camera.far );
export const cameraLogDepth = /*#__PURE__*/ uniform( 'float' ).onRenderUpdate( ( { camera } ) => 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
export const cameraProjectionMatrix = /*#__PURE__*/ uniform( 'mat4' ).onRenderUpdate( ( { camera } ) => camera.projectionMatrix );
export const cameraProjectionMatrixInverse = /*#__PURE__*/ uniform( 'mat4' ).onRenderUpdate( ( { camera } ) => camera.projectionMatrixInverse );
export const cameraViewMatrix = /*#__PURE__*/ uniform( 'mat4' ).onRenderUpdate( ( { camera } ) => camera.matrixWorldInverse );
export const cameraWorldMatrix = /*#__PURE__*/ uniform( 'mat4' ).onRenderUpdate( ( { camera } ) => camera.matrixWorld );
export const cameraNormalMatrix = /*#__PURE__*/ uniform( 'mat3' ).onRenderUpdate( ( { camera } ) => camera.normalMatrix );
export const cameraPosition = /*#__PURE__*/ uniform( new Vector3() ).onRenderUpdate( ( { camera }, self ) => self.value.setFromMatrixPosition( camera.matrixWorld ) );

@@ -369,2 +369,3 @@ import Node, { addNodeClass } from '../core/Node.js';

MaterialNode.POINT_WIDTH = 'pointWidth';
MaterialNode.DISPERSION = 'dispersion';

@@ -409,2 +410,3 @@ export default MaterialNode;

export const materialPointWidth = nodeImmutable( MaterialNode, MaterialNode.POINT_WIDTH );
export const materialDispersion = nodeImmutable( MaterialNode, MaterialNode.DISPERSION );
export const materialAnisotropyVector = uniform( new Vector2() ).onReference( function ( frame ) {

@@ -411,0 +413,0 @@

import Object3DNode from './Object3DNode.js';
import { addNodeClass } from '../core/Node.js';
import { nodeImmutable } from '../shadernode/ShaderNode.js';
import { uniform } from '../core/UniformNode.js';
import { Matrix4 } from 'three';

@@ -32,3 +34,4 @@ class ModelNode extends Object3DNode {

export const modelViewPosition = nodeImmutable( ModelNode, ModelNode.VIEW_POSITION );
export const modelWorldMatrixInverse = uniform( new Matrix4() ).onObjectUpdate( ( { object }, self ) => self.value.copy( object.matrixWorld ).invert() );
addNodeClass( 'ModelNode', ModelNode );

@@ -1,106 +0,14 @@

import Node, { addNodeClass } from '../core/Node.js';
import { attribute } from '../core/AttributeNode.js';
import { varying } from '../core/VaryingNode.js';
import { property } from '../core/PropertyNode.js';
import { normalize } from '../math/MathNode.js';
import { cameraViewMatrix } from './CameraNode.js';
import { modelNormalMatrix } from './ModelNode.js';
import { nodeImmutable, vec3 } from '../shadernode/ShaderNode.js';
import { vec3 } from '../shadernode/ShaderNode.js';
class NormalNode extends Node {
constructor( scope = NormalNode.LOCAL ) {
super( 'vec3' );
this.scope = scope;
}
isGlobal() {
return true;
}
getHash( /*builder*/ ) {
return `normal-${this.scope}`;
}
generate( builder ) {
const scope = this.scope;
let outputNode = null;
if ( scope === NormalNode.GEOMETRY ) {
const geometryAttribute = builder.hasGeometryAttribute( 'normal' );
if ( geometryAttribute === false ) {
outputNode = vec3( 0, 1, 0 );
} else {
outputNode = attribute( 'normal', 'vec3' );
}
} else if ( scope === NormalNode.LOCAL ) {
outputNode = varying( normalGeometry );
} else if ( scope === NormalNode.VIEW ) {
const vertexNode = modelNormalMatrix.mul( normalLocal );
outputNode = normalize( varying( vertexNode ) );
} else if ( scope === NormalNode.WORLD ) {
// To use inverseTransformDirection only inverse the param order like this: cameraViewMatrix.transformDirection( normalView )
const vertexNode = normalView.transformDirection( cameraViewMatrix );
outputNode = normalize( varying( vertexNode ) );
}
return outputNode.build( builder, this.getNodeType( builder ) );
}
serialize( data ) {
super.serialize( data );
data.scope = this.scope;
}
deserialize( data ) {
super.deserialize( data );
this.scope = data.scope;
}
}
NormalNode.GEOMETRY = 'geometry';
NormalNode.LOCAL = 'local';
NormalNode.VIEW = 'view';
NormalNode.WORLD = 'world';
export default NormalNode;
export const normalGeometry = nodeImmutable( NormalNode, NormalNode.GEOMETRY );
export const normalLocal = nodeImmutable( NormalNode, NormalNode.LOCAL ).temp( 'Normal' );
export const normalView = nodeImmutable( NormalNode, NormalNode.VIEW );
export const normalWorld = nodeImmutable( NormalNode, NormalNode.WORLD );
export const transformedNormalView = property( 'vec3', 'TransformedNormalView' );
export const transformedNormalWorld = transformedNormalView.transformDirection( cameraViewMatrix ).normalize();
export const transformedClearcoatNormalView = property( 'vec3', 'TransformedClearcoatNormalView' );
addNodeClass( 'NormalNode', NormalNode );
export const normalGeometry = /*#__PURE__*/ attribute( 'normal', 'vec3', vec3( 0, 1, 0 ) );
export const normalLocal = /*#__PURE__*/ normalGeometry.toVar( 'normalLocal' );
export const normalView = /*#__PURE__*/ varying( modelNormalMatrix.mul( normalLocal ), 'v_normalView' ).normalize().toVar( 'normalView' );
export const normalWorld = /*#__PURE__*/ varying( normalView.transformDirection( cameraViewMatrix ), 'v_normalWorld' ).normalize().toVar( 'transformedNormalWorld' );
export const transformedNormalView = /*#__PURE__*/ property( 'vec3', 'transformedNormalView' );
export const transformedNormalWorld = /*#__PURE__*/ transformedNormalView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedNormalWorld' );
export const transformedClearcoatNormalView = /*#__PURE__*/ property( 'vec3', 'transformedClearcoatNormalView' );

@@ -1,104 +0,10 @@

import Node, { addNodeClass } from '../core/Node.js';
import { attribute } from '../core/AttributeNode.js';
import { varying } from '../core/VaryingNode.js';
import { normalize } from '../math/MathNode.js';
import { modelWorldMatrix, modelViewMatrix } from './ModelNode.js';
import { nodeImmutable } from '../shadernode/ShaderNode.js';
class PositionNode extends Node {
constructor( scope = PositionNode.LOCAL ) {
super( 'vec3' );
this.scope = scope;
}
isGlobal() {
return true;
}
getHash( /*builder*/ ) {
return `position-${this.scope}`;
}
generate( builder ) {
const scope = this.scope;
let outputNode = null;
if ( scope === PositionNode.GEOMETRY ) {
outputNode = attribute( 'position', 'vec3' );
} else if ( scope === PositionNode.LOCAL ) {
outputNode = varying( positionGeometry );
} else if ( scope === PositionNode.WORLD ) {
const vertexPositionNode = modelWorldMatrix.mul( positionLocal );
outputNode = varying( vertexPositionNode );
} else if ( scope === PositionNode.VIEW ) {
const vertexPositionNode = modelViewMatrix.mul( positionLocal );
outputNode = varying( vertexPositionNode );
} else if ( scope === PositionNode.VIEW_DIRECTION ) {
const vertexPositionNode = positionView.negate();
outputNode = normalize( varying( vertexPositionNode ) );
} else if ( scope === PositionNode.WORLD_DIRECTION ) {
const vertexPositionNode = positionLocal.transformDirection( modelWorldMatrix );
outputNode = normalize( varying( vertexPositionNode ) );
}
return outputNode.build( builder, this.getNodeType( builder ) );
}
serialize( data ) {
super.serialize( data );
data.scope = this.scope;
}
deserialize( data ) {
super.deserialize( data );
this.scope = data.scope;
}
}
PositionNode.GEOMETRY = 'geometry';
PositionNode.LOCAL = 'local';
PositionNode.WORLD = 'world';
PositionNode.WORLD_DIRECTION = 'worldDirection';
PositionNode.VIEW = 'view';
PositionNode.VIEW_DIRECTION = 'viewDirection';
export default PositionNode;
export const positionGeometry = nodeImmutable( PositionNode, PositionNode.GEOMETRY );
export const positionLocal = nodeImmutable( PositionNode, PositionNode.LOCAL ).temp( 'Position' );
export const positionWorld = nodeImmutable( PositionNode, PositionNode.WORLD );
export const positionWorldDirection = nodeImmutable( PositionNode, PositionNode.WORLD_DIRECTION );
export const positionView = nodeImmutable( PositionNode, PositionNode.VIEW );
export const positionViewDirection = nodeImmutable( PositionNode, PositionNode.VIEW_DIRECTION );
addNodeClass( 'PositionNode', PositionNode );
export const positionGeometry = /*#__PURE__*/ attribute( 'position', 'vec3' );
export const positionLocal = /*#__PURE__*/ positionGeometry.toVar( 'positionLocal' );
export const positionWorld = /*#__PURE__*/ varying( modelWorldMatrix.mul( positionLocal ).xyz, 'v_positionWorld' );
export const positionWorldDirection = /*#__PURE__*/ varying( positionLocal.transformDirection( modelWorldMatrix ), 'v_positionWorldDirection' ).normalize().toVar( 'positionWorldDirection' );
export const positionView = /*#__PURE__*/ varying( modelViewMatrix.mul( positionLocal ).xyz, 'v_positionView' );
export const positionViewDirection = /*#__PURE__*/ varying( positionView.negate(), 'v_positionViewDirection' ).normalize().toVar( 'positionViewDirection' );

@@ -93,2 +93,8 @@ import Node, { addNodeClass } from '../core/Node.js';

if ( this.node === null ) {
this.updateValue();
}
return this.node.getNodeType( builder );

@@ -95,0 +101,0 @@

@@ -1,35 +0,6 @@

import Node, { addNodeClass } from '../core/Node.js';
import { cameraViewMatrix } from './CameraNode.js';
import { transformedNormalView } from './NormalNode.js';
import { positionViewDirection } from './PositionNode.js';
import { nodeImmutable } from '../shadernode/ShaderNode.js';
class ReflectVectorNode extends Node {
constructor() {
super( 'vec3' );
}
getHash( /*builder*/ ) {
return 'reflectVector';
}
setup() {
const reflectView = positionViewDirection.negate().reflect( transformedNormalView );
return reflectView.transformDirection( cameraViewMatrix );
}
}
export default ReflectVectorNode;
export const reflectVector = nodeImmutable( ReflectVectorNode );
addNodeClass( 'ReflectVectorNode', ReflectVectorNode );
export const reflectView = /*#__PURE__*/ positionViewDirection.negate().reflect( transformedNormalView );
export const reflectVector = /*#__PURE__*/ reflectView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' );

@@ -1,109 +0,23 @@

import Node, { addNodeClass } from '../core/Node.js';
import { attribute } from '../core/AttributeNode.js';
import { temp } from '../core/VarNode.js';
import { varying } from '../core/VaryingNode.js';
import { normalize } from '../math/MathNode.js';
import { cameraViewMatrix } from './CameraNode.js';
import { modelViewMatrix } from './ModelNode.js';
import { nodeImmutable, vec4 } from '../shadernode/ShaderNode.js';
import { tslFn, vec4 } from '../shadernode/ShaderNode.js';
class TangentNode extends Node {
export const tangentGeometry = /*#__PURE__*/ tslFn( ( stack, builder ) => {
constructor( scope = TangentNode.LOCAL ) {
if ( builder.geometry.hasAttribute( 'tangent' ) === false ) {
super();
builder.geometry.computeTangents();
this.scope = scope;
}
getHash( /*builder*/ ) {
return attribute( 'tangent', 'vec4' );
return `tangent-${this.scope}`;
} )();
}
getNodeType() {
const scope = this.scope;
if ( scope === TangentNode.GEOMETRY ) {
return 'vec4';
}
return 'vec3';
}
generate( builder ) {
const scope = this.scope;
let outputNode = null;
if ( scope === TangentNode.GEOMETRY ) {
outputNode = attribute( 'tangent', 'vec4' );
if ( builder.geometry.hasAttribute( 'tangent' ) === false ) {
builder.geometry.computeTangents();
}
} else if ( scope === TangentNode.LOCAL ) {
outputNode = varying( tangentGeometry.xyz );
} else if ( scope === TangentNode.VIEW ) {
const vertexNode = modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz;
outputNode = normalize( varying( vertexNode ) );
} else if ( scope === TangentNode.WORLD ) {
const vertexNode = tangentView.transformDirection( cameraViewMatrix );
outputNode = normalize( varying( vertexNode ) );
}
return outputNode.build( builder, this.getNodeType( builder ) );
}
serialize( data ) {
super.serialize( data );
data.scope = this.scope;
}
deserialize( data ) {
super.deserialize( data );
this.scope = data.scope;
}
}
TangentNode.GEOMETRY = 'geometry';
TangentNode.LOCAL = 'local';
TangentNode.VIEW = 'view';
TangentNode.WORLD = 'world';
export default TangentNode;
export const tangentGeometry = nodeImmutable( TangentNode, TangentNode.GEOMETRY );
export const tangentLocal = nodeImmutable( TangentNode, TangentNode.LOCAL );
export const tangentView = nodeImmutable( TangentNode, TangentNode.VIEW );
export const tangentWorld = nodeImmutable( TangentNode, TangentNode.WORLD );
export const transformedTangentView = temp( tangentView, 'TransformedTangentView' );
export const transformedTangentWorld = normalize( transformedTangentView.transformDirection( cameraViewMatrix ) );
addNodeClass( 'TangentNode', TangentNode );
export const tangentLocal = /*#__PURE__*/ tangentGeometry.xyz.toVar( 'tangentLocal' );
export const tangentView = /*#__PURE__*/ varying( modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz, 'v_tangentView' ).normalize().toVar( 'tangentView' );
export const tangentWorld = /*#__PURE__*/ varying( tangentView.transformDirection( cameraViewMatrix ), 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' );
export const transformedTangentView = /*#__PURE__*/ tangentView.toVar( 'transformedTangentView' );
export const transformedTangentWorld = /*#__PURE__*/ transformedTangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedTangentWorld' );

@@ -1,47 +0,3 @@

import { addNodeClass } from '../core/Node.js';
import AttributeNode from '../core/AttributeNode.js';
import { nodeObject } from '../shadernode/ShaderNode.js';
import { attribute } from '../core/AttributeNode.js';
class UVNode extends AttributeNode {
constructor( index = 0 ) {
super( null, 'vec2' );
this.isUVNode = true;
this.index = index;
}
getAttributeName( /*builder*/ ) {
const index = this.index;
return 'uv' + ( index > 0 ? index : '' );
}
serialize( data ) {
super.serialize( data );
data.index = this.index;
}
deserialize( data ) {
super.deserialize( data );
this.index = data.index;
}
}
export default UVNode;
export const uv = ( ...params ) => nodeObject( new UVNode( ...params ) );
addNodeClass( 'UVNode', UVNode );
export const uv = ( index ) => attribute( 'uv' + ( index > 0 ? index : '' ), 'vec2' );

@@ -7,6 +7,8 @@ import Node, { addNodeClass } from './Node.js';

constructor( attributeName, nodeType = null ) {
constructor( attributeName, nodeType = null, defaultNode = null ) {
super( nodeType );
this.defaultNode = defaultNode;
this._attributeName = attributeName;

@@ -97,4 +99,14 @@

return builder.generateConst( nodeType );
const { defaultNode } = this;
if ( defaultNode !== null ) {
return defaultNode.build( builder, nodeType );
} else {
return builder.generateConst( nodeType );
}
}

@@ -108,4 +120,4 @@

export const attribute = ( name, nodeType ) => nodeObject( new AttributeNode( name, nodeType ) );
export const attribute = ( name, nodeType, defaultNode ) => nodeObject( new AttributeNode( name, nodeType, nodeObject( defaultNode ) ) );
addNodeClass( 'AttributeNode', AttributeNode );

@@ -23,2 +23,8 @@ import Node, { addNodeClass } from './Node.js';

analyze( builder ) {
this.node.build( builder );
}
setup( builder ) {

@@ -25,0 +31,0 @@

@@ -28,2 +28,4 @@ import { EventDispatcher } from 'three';

this.global = false;
this.isNode = true;

@@ -102,3 +104,3 @@

return false;
return this.global;

@@ -168,2 +170,11 @@ }

getElementType( builder ) {
const type = this.getNodeType( builder );
const elementType = builder.getElementType( type );
return elementType;
}
getNodeType( builder ) {

@@ -196,5 +207,7 @@

let index = 0;
for ( const childNode of this.getChildren() ) {
nodeProperties[ '_node' + childNode.id ] = childNode;
nodeProperties[ 'node' + index ++ ] = childNode;

@@ -201,0 +214,0 @@ }

@@ -83,3 +83,3 @@ import NodeUniform from './NodeUniform.js';

this.flowNodes = { vertex: [], fragment: [], compute: [] };
this.flowCode = { vertex: '', fragment: '', compute: [] };
this.flowCode = { vertex: '', fragment: '', compute: '' };
this.uniforms = { vertex: [], fragment: [], compute: [], index: 0 };

@@ -419,8 +419,2 @@ this.structs = { vertex: [], fragment: [], compute: [], index: 0 };

generateMethod( method ) {
return method;
}
hasGeometryAttribute( name ) {

@@ -478,3 +472,3 @@

return type === 'void' || type === 'property' || type === 'sampler' || type === 'texture' || type === 'cubeTexture' || type === 'storageTexture';
return type === 'void' || type === 'property' || type === 'sampler' || type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D';

@@ -504,2 +498,12 @@ }

getElementType( type ) {
if ( type === 'mat2' ) return 'vec2';
if ( type === 'mat3' ) return 'vec3';
if ( type === 'mat4' ) return 'vec4';
return this.getComponentType( type );
}
getComponentType( type ) {

@@ -526,3 +530,3 @@

if ( type === 'color' ) return 'vec3';
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' ) return 'vec4';
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) return 'vec4';

@@ -915,3 +919,5 @@ return type;

const previousVars = this.vars;
const previousCache = this.cache;
const previousBuildStage = this.buildStage;
const previousStack = this.stack;

@@ -924,2 +930,4 @@ const flow = {

this.vars = {};
this.cache = new NodeCache();
this.stack = stack();

@@ -938,2 +946,5 @@ for ( const buildStage of defaultBuildStages ) {

this.vars = previousVars;
this.cache = previousCache;
this.stack = previousStack;
this.setBuildStage( previousBuildStage );

@@ -940,0 +951,0 @@

@@ -6,3 +6,3 @@ class NodeKeywords {

this.keywords = [];
this.nodes = [];
this.nodes = {};
this.keywordsCallback = {};

@@ -9,0 +9,0 @@

@@ -36,7 +36,3 @@ import Node, { addNodeClass } from './Node.js';

const nodeVar = builder.getVarFromNode( this );
nodeVar.isOutputStructVar = true;
const propertyName = builder.getPropertyName( nodeVar );
const propertyName = builder.getOutputStructName();
const members = this.members;

@@ -43,0 +39,0 @@

@@ -81,3 +81,4 @@ import Node, { addNodeClass } from './Node.js';

export const attenuationColor = nodeImmutable( PropertyNode, 'color', 'AttenuationColor' );
export const dispersion = nodeImmutable( PropertyNode, 'float', 'Dispersion' );
addNodeClass( 'PropertyNode', PropertyNode );

@@ -38,19 +38,50 @@ import Node, { addNodeClass } from './Node.js';

setupVarying( builder ) {
const properties = builder.getNodeProperties( this );
let varying = properties.varying;
if ( varying === undefined ) {
const name = this.name;
const type = this.getNodeType( builder );
properties.varying = varying = builder.getVaryingFromNode( this, name, type );
properties.node = this.node;
}
// this property can be used to check if the varying can be optimized for a variable
varying.needsInterpolation || ( varying.needsInterpolation = ( builder.shaderStage === 'fragment' ) );
return varying;
}
setup( builder ) {
this.setupVarying( builder );
}
generate( builder ) {
const { name, node } = this;
const type = this.getNodeType( builder );
const properties = builder.getNodeProperties( this );
const varying = this.setupVarying( builder );
const nodeVarying = builder.getVaryingFromNode( this, name, type );
if ( properties.propertyName === undefined ) {
// this property can be used to check if the varying can be optimized for a var
nodeVarying.needsInterpolation || ( nodeVarying.needsInterpolation = ( builder.shaderStage === 'fragment' ) );
const type = this.getNodeType( builder );
const propertyName = builder.getPropertyName( varying, NodeShaderStage.VERTEX );
const propertyName = builder.getPropertyName( nodeVarying, NodeShaderStage.VERTEX );
// force node run in vertex stage
builder.flowNodeFromShaderStage( NodeShaderStage.VERTEX, this.node, type, propertyName );
// force node run in vertex stage
builder.flowNodeFromShaderStage( NodeShaderStage.VERTEX, node, type, propertyName );
properties.propertyName = propertyName;
return builder.getPropertyName( nodeVarying );
}
return builder.getPropertyName( varying );
}

@@ -57,0 +88,0 @@

@@ -11,3 +11,6 @@ import TempNode from '../core/TempNode.js';

import QuadMesh from '../../objects/QuadMesh.js';
import { NoToneMapping, Vector2 } from 'three';
const _size = new Vector2();
const quadMeshComp = new QuadMesh();

@@ -62,2 +65,9 @@

renderer.getDrawingBufferSize( _size );
this.setSize( _size.x, _size.y );
const currentToneMapping = renderer.toneMapping;
const currentToneMappingNode = renderer.toneMappingNode;
const currentRenderTarget = renderer.getRenderTarget();

@@ -69,2 +79,4 @@ const currentTexture = textureNode.value;

// comp
renderer.toneMapping = NoToneMapping;
renderer.toneMappingNode = null;
renderer.setRenderTarget( this._compRT );

@@ -78,5 +90,5 @@ quadMeshComp.render( renderer );

// set size before swapping fails
this.setSize( map.image.width, map.image.height );
renderer.toneMapping = currentToneMapping;
renderer.toneMappingNode = currentToneMappingNode;
renderer.setRenderTarget( currentRenderTarget );

@@ -83,0 +95,0 @@ textureNode.value = currentTexture;

@@ -10,2 +10,4 @@ import { addNodeClass } from '../core/Node.js';

const _size = new Vector2();
class PassTextureNode extends TextureNode {

@@ -139,3 +141,3 @@

const size = renderer.getSize( new Vector2() );
const size = renderer.getSize( _size );

@@ -142,0 +144,0 @@ this.setSize( size.width, size.height );

@@ -36,3 +36,3 @@ import Node, { addNodeClass } from '../core/Node.js';

updateType = NodeUpdateType.FRAME;
updateType = NodeUpdateType.RENDER;

@@ -39,0 +39,0 @@ }

@@ -9,3 +9,3 @@ import BRDF_Lambert from './BSDF/BRDF_Lambert.js';

import LightingModel from '../core/LightingModel.js';
import { diffuseColor, specularColor, specularF90, roughness, clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, ior, thickness, transmission, attenuationDistance, attenuationColor } from '../core/PropertyNode.js';
import { diffuseColor, specularColor, specularF90, roughness, clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, ior, thickness, transmission, attenuationDistance, attenuationColor, dispersion } from '../core/PropertyNode.js';
import { transformedNormalView, transformedClearcoatNormalView, transformedNormalWorld } from '../accessors/NormalNode.js';

@@ -21,2 +21,3 @@ import { positionViewDirection, positionWorld } from '../accessors/PositionNode.js';

import { viewportMipTexture } from '../display/ViewportTextureNode.js';
import { loop } from '../utils/LoopNode.js';

@@ -107,17 +108,58 @@ //

const getIBLVolumeRefraction = tslFn( ( [ n, v, roughness, diffuseColor, specularColor, specularF90, position, modelMatrix, viewMatrix, projMatrix, ior, thickness, attenuationColor, attenuationDistance ] ) => {
const getIBLVolumeRefraction = tslFn( ( [ n, v, roughness, diffuseColor, specularColor, specularF90, position, modelMatrix, viewMatrix, projMatrix, ior, thickness, attenuationColor, attenuationDistance, dispersion ] ) => {
const transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
const refractedRayExit = position.add( transmissionRay );
let transmittedLight, transmittance;
// Project refracted vector on the framebuffer, while mapping to normalized device coordinates.
const ndcPos = projMatrix.mul( viewMatrix.mul( vec4( refractedRayExit, 1.0 ) ) );
const refractionCoords = vec2( ndcPos.xy.div( ndcPos.w ) ).toVar();
refractionCoords.addAssign( 1.0 );
refractionCoords.divAssign( 2.0 );
refractionCoords.assign( vec2( refractionCoords.x, refractionCoords.y.oneMinus() ) ); // webgpu
if ( dispersion ) {
// Sample framebuffer to get pixel the refracted ray hits.
const transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
const transmittance = diffuseColor.mul( volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ) );
transmittedLight = vec4().toVar();
transmittance = vec3().toVar();
const halfSpread = ior.sub( 1.0 ).mul( dispersion.mul( 0.025 ) );
const iors = vec3( ior.sub( halfSpread ), ior, ior.add( halfSpread ) );
loop( { start: 0, end: 3 }, ( { i } ) => {
const ior = iors.element( i );
const transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
const refractedRayExit = position.add( transmissionRay );
// Project refracted vector on the framebuffer, while mapping to normalized device coordinates.
const ndcPos = projMatrix.mul( viewMatrix.mul( vec4( refractedRayExit, 1.0 ) ) );
const refractionCoords = vec2( ndcPos.xy.div( ndcPos.w ) ).toVar();
refractionCoords.addAssign( 1.0 );
refractionCoords.divAssign( 2.0 );
refractionCoords.assign( vec2( refractionCoords.x, refractionCoords.y.oneMinus() ) ); // webgpu
// Sample framebuffer to get pixel the refracted ray hits.
const transmissionSample = getTransmissionSample( refractionCoords, roughness, ior );
transmittedLight.element( i ).assign( transmissionSample.element( i ) );
transmittedLight.a.addAssign( transmissionSample.a );
transmittance.element( i ).assign( diffuseColor.element( i ).mul( volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ).element( i ) ) );
} );
transmittedLight.a.divAssign( 3.0 );
} else {
const transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
const refractedRayExit = position.add( transmissionRay );
// Project refracted vector on the framebuffer, while mapping to normalized device coordinates.
const ndcPos = projMatrix.mul( viewMatrix.mul( vec4( refractedRayExit, 1.0 ) ) );
const refractionCoords = vec2( ndcPos.xy.div( ndcPos.w ) ).toVar();
refractionCoords.addAssign( 1.0 );
refractionCoords.divAssign( 2.0 );
refractionCoords.assign( vec2( refractionCoords.x, refractionCoords.y.oneMinus() ) ); // webgpu
// Sample framebuffer to get pixel the refracted ray hits.
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
transmittance = diffuseColor.mul( volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ) );
}
const attenuatedColor = transmittance.rgb.mul( transmittedLight.rgb );

@@ -217,3 +259,3 @@ const dotNV = n.dot( v ).clamp();

const baseIOR = Fresnel0ToIor( baseF0.clamp( 0.0, 0.9999 ) ); // guard against 1.0
const R1 = IorToFresnel0( baseIOR, iridescenceIOR.vec3() );
const R1 = IorToFresnel0( baseIOR, iridescenceIOR.toVec3() );
const R23 = F_Schlick( { f0: R1, f90: 1.0, dotVH: cosTheta2 } );

@@ -296,3 +338,3 @@ const phi23 = vec3(

const clearcoatF0 = vec3( 0.04 );
const clearcoatF90 = vec3( 1 );
const clearcoatF90 = float( 1 );

@@ -303,3 +345,3 @@ //

constructor( clearcoat = false, sheen = false, iridescence = false, anisotropy = false, transmission = false ) {
constructor( clearcoat = false, sheen = false, iridescence = false, anisotropy = false, transmission = false, dispersion = false ) {

@@ -313,2 +355,3 @@ super();

this.transmission = transmission;
this.dispersion = dispersion;

@@ -378,3 +421,4 @@ this.clearcoatRadiance = null;

attenuationColor,
attenuationDistance
attenuationDistance,
this.dispersion ? dispersion : null
);

@@ -381,0 +425,0 @@

@@ -185,3 +185,3 @@ import LightingNode from './LightingNode.js';

const { rtt, light } = this;
const { renderer, scene } = frame;
const { renderer, scene, camera } = frame;

@@ -195,2 +195,3 @@ const currentOverrideMaterial = scene.overrideMaterial;

light.shadow.updateMatrices( light );
light.shadow.camera.layers.mask = camera.layers.mask;

@@ -197,0 +198,0 @@ const currentToneMapping = renderer.toneMapping;

@@ -56,2 +56,14 @@ import Node from '../core/Node.js';

analyze( builder ) {
const properties = builder.getDataFromNode( this );
for ( const node of properties.nodes ) {
node.build( builder );
}
}
setup( builder ) {

@@ -74,2 +86,7 @@

const properties = builder.getDataFromNode( this );
properties.nodes = stack.nodes;
//
lightingModel.start( context, stack, builder );

@@ -76,0 +93,0 @@

@@ -150,3 +150,3 @@ import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';

worldPos.assign( positionGeometry.y.lessThan( 0.5 ).cond( start, end) );
worldPos.assign( positionGeometry.y.lessThan( 0.5 ).cond( start, end ) );

@@ -153,0 +153,0 @@ // height offset

@@ -15,4 +15,7 @@ // @TODO: We can simplify "export { default as SomeNode, other, exports } from '...'" to just "export * from '...'" if we will use only named exports

export { default as MeshSSSNodeMaterial } from './MeshSSSNodeMaterial.js';
export { default as MeshToonNodeMaterial } from './MeshToonNodeMaterial.js';
export { default as MeshMatcapNodeMaterial } from './MeshMatcapNodeMaterial.js';
export { default as PointsNodeMaterial } from './PointsNodeMaterial.js';
export { default as SpriteNodeMaterial } from './SpriteNodeMaterial.js';
export { default as ShadowNodeMaterial } from './ShadowNodeMaterial.js';
export { default as VolumeNodeMaterial } from './VolumeNodeMaterial.js';
import { addNodeMaterial } from './NodeMaterial.js';
import { transformedClearcoatNormalView } from '../accessors/NormalNode.js';
import { clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, specularColor, specularF90, diffuseColor, metalness, roughness, anisotropy, alphaT, anisotropyT, anisotropyB, ior, transmission, thickness, attenuationDistance, attenuationColor } from '../core/PropertyNode.js';
import { materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialSpecularIntensity, materialSpecularColor, materialAnisotropy, materialIOR, materialTransmission, materialThickness, materialAttenuationDistance, materialAttenuationColor } from '../accessors/MaterialNode.js';
import { clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, specularColor, specularF90, diffuseColor, metalness, roughness, anisotropy, alphaT, anisotropyT, anisotropyB, ior, transmission, thickness, attenuationDistance, attenuationColor, dispersion } from '../core/PropertyNode.js';
import { materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialSpecularIntensity, materialSpecularColor, materialAnisotropy, materialIOR, materialTransmission, materialThickness, materialAttenuationDistance, materialAttenuationColor, materialDispersion } from '../accessors/MaterialNode.js';
import { float, vec2, vec3, If } from '../shadernode/ShaderNode.js';
import getRoughness from '../functions/material/getRoughness.js';
import { TBNViewMatrix } from '../accessors/AccessorsUtils.js';

@@ -41,2 +42,3 @@ import PhysicalLightingModel from '../functions/PhysicalLightingModel.js';

this.attenuationColorNode = null;
this.dispersionNode = null;

@@ -81,2 +83,8 @@ this.anisotropyNode = null;

get useDispersion() {
return this.dispersion > 0 || this.dispersionNode !== null;
}
setupSpecular() {

@@ -94,3 +102,3 @@

return new PhysicalLightingModel( this.useClearcoat, this.useSheen, this.useIridescence, this.useAnisotropy, this.useTransmission );
return new PhysicalLightingModel( this.useClearcoat, this.useSheen, this.useIridescence, this.useAnisotropy, this.useTransmission, this.useDispersion );

@@ -111,3 +119,3 @@ }

clearcoat.assign( clearcoatNode );
clearcoatRoughness.assign( clearcoatRoughnessNode );
clearcoatRoughness.assign( getRoughness( { roughness: clearcoatRoughnessNode } ) );

@@ -183,2 +191,10 @@ }

if ( this.useDispersion ) {
const dispersionNode = this.dispersionNode ? float( this.dispersionNode ) : materialDispersion;
dispersion.assign( dispersionNode );
}
}

@@ -220,2 +236,3 @@

this.attenuationColorNode = source.attenuationColorNode;
this.dispersionNode = source.dispersionNode;

@@ -222,0 +239,0 @@ this.anisotropyNode = source.anisotropyNode;

@@ -1,2 +0,2 @@

import { Material, ShaderMaterial } from 'three';
import { Material } from 'three';
import { getNodeChildren, getCacheKey } from '../core/NodeUtils.js';

@@ -7,3 +7,3 @@ import { attribute } from '../core/AttributeNode.js';

import { modelViewProjection } from '../accessors/ModelViewProjectionNode.js';
import { transformedNormalView } from '../accessors/NormalNode.js';
import { transformedNormalView, normalLocal } from '../accessors/NormalNode.js';
import { instance } from '../accessors/InstanceNode.js';

@@ -31,3 +31,3 @@ import { batch } from '../accessors/BatchNode.js';

class NodeMaterial extends ShaderMaterial {
class NodeMaterial extends Material {

@@ -221,2 +221,12 @@ constructor() {

if ( this.displacementMap ) {
const displacementMap = materialReference( 'displacementMap', 'texture' );
const displacementScale = materialReference( 'displacementScale', 'float' );
const displacementBias = materialReference( 'displacementBias', 'float' );
positionLocal.addAssign( normalLocal.normalize().mul( ( displacementMap.x.mul( displacementScale ).add( displacementBias ) ) ) );
}
if ( object.isBatchedMesh ) {

@@ -454,4 +464,2 @@

Object.assign( this.defines, material.defines );
const descriptors = Object.getOwnPropertyDescriptors( material.constructor.prototype );

@@ -458,0 +466,0 @@

@@ -18,7 +18,7 @@ import Node, { addNodeClass } from '../core/Node.js';

const state = this.seedNode.uint().mul( 747796405 ).add( 2891336453 );
const state = this.seedNode.toUint().mul( 747796405 ).add( 2891336453 );
const word = state.shiftRight( state.shiftRight( 28 ).add( 4 ) ).bitXor( state ).mul( 277803737 );
const result = word.shiftRight( 22 ).bitXor( word );
return result.float().mul( 1 / 2 ** 32 ); // Convert to range [0, 1)
return result.toFloat().mul( 1 / 2 ** 32 ); // Convert to range [0, 1)

@@ -25,0 +25,0 @@ }

@@ -80,6 +80,6 @@ // @TODO: We can simplify "export { default as SomeNode, other, exports } from '...'" to just "export * from '...'" if we will use only named exports

export { default as UniformsNode, uniforms } from './accessors/UniformsNode.js';
export { default as BitangentNode, bitangentGeometry, bitangentLocal, bitangentView, bitangentWorld, transformedBitangentView, transformedBitangentWorld } from './accessors/BitangentNode.js';
export * from './accessors/BitangentNode.js';
export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute, instancedBufferAttribute, instancedDynamicBufferAttribute } from './accessors/BufferAttributeNode.js';
export { default as BufferNode, buffer } from './accessors/BufferNode.js';
export { default as CameraNode, cameraProjectionMatrix, cameraProjectionMatrixInverse, cameraViewMatrix, cameraNormalMatrix, cameraWorldMatrix, cameraPosition, cameraNear, cameraFar, cameraLogDepth } from './accessors/CameraNode.js';
export * from './accessors/CameraNode.js';
export { default as VertexColorNode, vertexColor } from './accessors/VertexColorNode.js';

@@ -89,3 +89,3 @@ export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';

export { default as BatchNode, batch } from './accessors/BatchNode.js';
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecular, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth, materialAnisotropy, materialAnisotropyVector } from './accessors/MaterialNode.js';
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecular, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth, materialAnisotropy, materialAnisotropyVector, materialDispersion } from './accessors/MaterialNode.js';
export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';

@@ -95,17 +95,18 @@ export { default as RendererReferenceNode, rendererReference } from './accessors/RendererReferenceNode.js';

export { default as TextureBicubicNode, textureBicubic } from './accessors/TextureBicubicNode.js';
export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale } from './accessors/ModelNode.js';
export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale, modelWorldMatrixInverse } from './accessors/ModelNode.js';
export { default as ModelViewProjectionNode, modelViewProjection } from './accessors/ModelViewProjectionNode.js';
export { default as NormalNode, normalGeometry, normalLocal, normalView, normalWorld, transformedNormalView, transformedNormalWorld, transformedClearcoatNormalView } from './accessors/NormalNode.js';
export * from './accessors/NormalNode.js';
export { default as Object3DNode, objectDirection, objectViewMatrix, objectNormalMatrix, objectWorldMatrix, objectPosition, objectScale, objectViewPosition } from './accessors/Object3DNode.js';
export { default as PointUVNode, pointUV } from './accessors/PointUVNode.js';
export { default as PositionNode, positionGeometry, positionLocal, positionWorld, positionWorldDirection, positionView, positionViewDirection } from './accessors/PositionNode.js';
export * from './accessors/PositionNode.js';
export { default as ReferenceNode, reference, referenceBuffer } from './accessors/ReferenceNode.js';
export { default as ReflectVectorNode, reflectVector } from './accessors/ReflectVectorNode.js';
export * from './accessors/ReflectVectorNode.js';
export { default as SkinningNode, skinning } from './accessors/SkinningNode.js';
export { default as SceneNode, backgroundBlurriness, backgroundIntensity } from './accessors/SceneNode.js';
export { default as StorageBufferNode, storage, storageObject } from './accessors/StorageBufferNode.js';
export { default as TangentNode, tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView, transformedTangentWorld } from './accessors/TangentNode.js';
export * from './accessors/TangentNode.js';
export { default as TextureNode, texture, textureLoad, /*textureLevel,*/ sampler } from './accessors/TextureNode.js';
export { default as TextureStoreNode, textureStore } from './accessors/TextureStoreNode.js';
export { default as UVNode, uv } from './accessors/UVNode.js';
export { default as StorageTextureNode, storageTexture, textureStore, storageTextureReadOnly, storageTextureReadWrite } from './accessors/StorageTextureNode.js';
export { default as Texture3DNode, texture3D } from './accessors/Texture3DNode.js';
export * from './accessors/UVNode.js';
export { default as UserDataNode, userData } from './accessors/UserDataNode.js';

@@ -131,3 +132,3 @@

export { default as PassNode, pass, depthPass } from './display/PassNode.js';
export { default as PassNode, pass, texturePass, depthPass } from './display/PassNode.js';

@@ -134,0 +135,0 @@ // code

@@ -254,6 +254,12 @@ import Node, { addNodeClass } from '../core/Node.js';

const { outputNode } = builder.getNodeProperties( this );
const properties = builder.getNodeProperties( this );
return outputNode ? outputNode.getNodeType( builder ) : super.getNodeType( builder );
if ( properties.outputNode === null ) {
properties.outputNode = this.setupOutput( builder );
}
return properties.outputNode.getNodeType( builder );
}

@@ -306,2 +312,10 @@

const { outputNode } = builder.getNodeProperties( this );
return outputNode || this.setupOutput( builder );
}
setupOutput( builder ) {
builder.addStack();

@@ -522,2 +536,12 @@

addNodeElement( 'toGlobal', ( node ) => {
node.global = true;
return node;
} );
//
export const setCurrentStack = ( stack ) => {

@@ -592,33 +616,31 @@

addNodeElement( 'color', color );
addNodeElement( 'float', float );
addNodeElement( 'int', int );
addNodeElement( 'uint', uint );
addNodeElement( 'bool', bool );
addNodeElement( 'vec2', vec2 );
addNodeElement( 'ivec2', ivec2 );
addNodeElement( 'uvec2', uvec2 );
addNodeElement( 'bvec2', bvec2 );
addNodeElement( 'vec3', vec3 );
addNodeElement( 'ivec3', ivec3 );
addNodeElement( 'uvec3', uvec3 );
addNodeElement( 'bvec3', bvec3 );
addNodeElement( 'vec4', vec4 );
addNodeElement( 'ivec4', ivec4 );
addNodeElement( 'uvec4', uvec4 );
addNodeElement( 'bvec4', bvec4 );
addNodeElement( 'mat2', mat2 );
addNodeElement( 'imat2', imat2 );
addNodeElement( 'umat2', umat2 );
addNodeElement( 'bmat2', bmat2 );
addNodeElement( 'mat3', mat3 );
addNodeElement( 'imat3', imat3 );
addNodeElement( 'umat3', umat3 );
addNodeElement( 'bmat3', bmat3 );
addNodeElement( 'mat4', mat4 );
addNodeElement( 'imat4', imat4 );
addNodeElement( 'umat4', umat4 );
addNodeElement( 'bmat4', bmat4 );
addNodeElement( 'string', string );
addNodeElement( 'arrayBuffer', arrayBuffer );
addNodeElement( 'toColor', color );
addNodeElement( 'toFloat', float );
addNodeElement( 'toInt', int );
addNodeElement( 'toUint', uint );
addNodeElement( 'toBool', bool );
addNodeElement( 'toVec2', vec2 );
addNodeElement( 'toIvec2', ivec2 );
addNodeElement( 'toUvec2', uvec2 );
addNodeElement( 'toBvec2', bvec2 );
addNodeElement( 'toVec3', vec3 );
addNodeElement( 'toIvec3', ivec3 );
addNodeElement( 'toUvec3', uvec3 );
addNodeElement( 'toBvec3', bvec3 );
addNodeElement( 'toVec4', vec4 );
addNodeElement( 'toIvec4', ivec4 );
addNodeElement( 'toUvec4', uvec4 );
addNodeElement( 'toBvec4', bvec4 );
addNodeElement( 'toMat2', mat2 );
addNodeElement( 'toImat2', imat2 );
addNodeElement( 'toUmat2', umat2 );
addNodeElement( 'toBmat2', bmat2 );
addNodeElement( 'toMat3', mat3 );
addNodeElement( 'toImat3', imat3 );
addNodeElement( 'toUmat3', umat3 );
addNodeElement( 'toBmat3', bmat3 );
addNodeElement( 'toMat4', mat4 );
addNodeElement( 'toImat4', imat4 );
addNodeElement( 'toUmat4', umat4 );
addNodeElement( 'toBmat4', bmat4 );

@@ -625,0 +647,0 @@ // basic nodes

@@ -18,3 +18,3 @@ import Node, { addNodeClass } from '../core/Node.js';

return this.node.getNodeType( builder );
return this.node.getElementType( builder );

@@ -21,0 +21,0 @@ }

@@ -20,3 +20,3 @@ import TempNode from '../core/TempNode.js';

return vec2( x.dot( transformedNormalView ), y.dot( transformedNormalView ) ).mul( 0.495 ).add( 0.5 );
return vec2( x.dot( transformedNormalView ), y.dot( transformedNormalView ) ).mul( 0.495 ).add( 0.5 ); // 0.495 to remove artifacts caused by undersized matcap disks

@@ -23,0 +23,0 @@ }

@@ -92,4 +92,4 @@ import UniformNode from '../core/UniformNode.js';

export const timerDelta = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.DELTA, timeScale, value ) );
export const frameId = nodeImmutable( TimerNode, TimerNode.FRAME ).uint();
export const frameId = nodeImmutable( TimerNode, TimerNode.FRAME ).toUint();
addNodeClass( 'TimerNode', TimerNode );

@@ -213,3 +213,3 @@ import {

renderer.copyFramebufferToTexture( screenPositionPixels, tempMap );
renderer.copyFramebufferToTexture( tempMap, screenPositionPixels );

@@ -226,3 +226,3 @@ // render pink quad

renderer.copyFramebufferToTexture( screenPositionPixels, occlusionMap );
renderer.copyFramebufferToTexture( occlusionMap, screenPositionPixels );

@@ -229,0 +229,0 @@ // restore graphics

@@ -45,3 +45,3 @@ import {

renderer.getClearColor( this._oldClearColor );
renderer.setClearColor( this.clearColor );
renderer.setClearColor( this.clearColor, renderer.getClearAlpha() );

@@ -48,0 +48,0 @@ }

@@ -25,2 +25,4 @@ import DataMap from './DataMap.js';

return attributeData;
}

@@ -27,0 +29,0 @@

@@ -125,2 +125,6 @@ import DataMap from './DataMap.js';

} else if ( binding.isSampler ) {
binding.update();
} else if ( binding.isSampledTexture ) {

@@ -140,2 +144,15 @@

const textureData = backend.get( binding.texture );
if ( backend.isWebGPUBackend === true && textureData.texture === undefined && textureData.externalTexture === undefined ) {
// TODO: Remove this once we found why updated === false isn't bound to a texture in the WebGPU backend
console.error( 'Bindings._update: binding should be available:', binding, updated, binding.texture, binding.textureNode.value );
this.textures.updateTexture( binding.texture );
needsBindingsUpdate = true;
}
if ( texture.isStorageTexture === true ) {

@@ -142,0 +159,0 @@

@@ -11,22 +11,14 @@ export default class ChainMap {

if ( Array.isArray( keys ) ) {
let map = this.weakMap;
let map = this.weakMap;
for ( let i = 0; i < keys.length; i ++ ) {
for ( let i = 0; i < keys.length; i ++ ) {
map = map.get( keys[ i ] );
map = map.get( keys[ i ] );
if ( map === undefined ) return undefined;
if ( map === undefined ) return undefined;
}
}
return map.get( keys[ keys.length - 1 ] );
return map.get( keys[ keys.length - 1 ] );
} else {
return super.get( keys );
}
}

@@ -36,24 +28,16 @@

if ( Array.isArray( keys ) ) {
let map = this.weakMap;
let map = this.weakMap;
for ( let i = 0; i < keys.length; i ++ ) {
for ( let i = 0; i < keys.length; i ++ ) {
const key = keys[ i ];
const key = keys[ i ];
if ( map.has( key ) === false ) map.set( key, new WeakMap() );
if ( map.has( key ) === false ) map.set( key, new WeakMap() );
map = map.get( key );
map = map.get( key );
}
}
return map.set( keys[ keys.length - 1 ], value );
return map.set( keys[ keys.length - 1 ], value );
} else {
return super.set( keys, value );
}
}

@@ -63,30 +47,16 @@

if ( Array.isArray( keys ) ) {
let map = this.weakMap;
let map = this.weakMap;
for ( let i = 0; i < keys.length; i ++ ) {
for ( let i = 0; i < keys.length; i ++ ) {
map = map.get( keys[ i ] );
map = map.get( keys[ i ] );
if ( map === undefined ) return false;
if ( map === undefined ) return false;
}
return map.delete( keys[ keys.length - 1 ] );
} else {
return super.delete( keys );
}
}
return map.delete( keys[ keys.length - 1 ] );
dispose() {
this.weakMap.clear();
}
}
import { Matrix3, Plane, Vector4 } from 'three';
const _plane = new Plane();
const _viewNormalMatrix = new Matrix3();

@@ -23,2 +22,3 @@ let _clippingContextVersion = 0;

this.parentVersion = 0;
this.viewNormalMatrix = new Matrix3();

@@ -34,3 +34,3 @@ }

_plane.copy( source[ i ] ).applyMatrix4( this.viewMatrix, _viewNormalMatrix );
_plane.copy( source[ i ] ).applyMatrix4( this.viewMatrix, this.viewNormalMatrix );

@@ -54,3 +54,3 @@ const v = planes[ offset + i ];

_viewNormalMatrix.getNormalMatrix( this.viewMatrix );
this.viewNormalMatrix.getNormalMatrix( this.viewMatrix );

@@ -112,4 +112,4 @@ let update = false;

this.viewMatrix = parent.viewMatrix;
this.viewNormalMatrix = parent.viewNormalMatrix;
update = true;

@@ -116,0 +116,0 @@

@@ -5,3 +5,3 @@ import { SampledTexture } from '../SampledTexture.js';

constructor( name, textureNode ) {
constructor( name, textureNode, access = null ) {

@@ -12,2 +12,4 @@ super( name, textureNode ? textureNode.value : null );

this.access = access;
}

@@ -41,5 +43,5 @@

constructor( name, textureNode ) {
constructor( name, textureNode, access ) {
super( name, textureNode );
super( name, textureNode, access );

@@ -52,2 +54,14 @@ this.isSampledCubeTexture = true;

export { NodeSampledTexture, NodeSampledCubeTexture };
class NodeSampledTexture3D extends NodeSampledTexture {
constructor( name, textureNode, access ) {
super( name, textureNode, access );
this.isSampledTexture3D = true;
}
}
export { NodeSampledTexture, NodeSampledCubeTexture, NodeSampledTexture3D };

@@ -13,4 +13,10 @@ import Sampler from '../Sampler.js';

update() {
this.texture = this.textureNode.value;
}
}
export default NodeSampler;

@@ -70,3 +70,3 @@ import DataMap from './DataMap.js';

if ( previousPipeline && previousPipeline.usedTimes === 0 ) this._releasePipeline( computeNode );
if ( previousPipeline && previousPipeline.usedTimes === 0 ) this._releasePipeline( previousPipeline );

@@ -209,3 +209,3 @@ pipeline = this._getComputePipeline( computeNode, stageCompute, cacheKey, bindings );

super.delete( object );
return super.delete( object );

@@ -212,0 +212,0 @@ }

@@ -18,2 +18,3 @@ import Animation from './Animation.js';

import QuadMesh from '../../objects/QuadMesh.js';
import RenderBundles from './RenderBundles.js';

@@ -91,2 +92,3 @@ const _scene = new Scene();

this._pipelines = null;
this._bundles = null;
this._renderLists = null;

@@ -116,2 +118,3 @@ this._renderContexts = null;

this._currentRenderObjectFunction = null;
this._currentRenderBundle = null;

@@ -177,2 +180,3 @@ this._handleObjectFunction = this._renderObjectDirect;

this._renderLists = new RenderLists();
this._bundles = new RenderBundles();
this._renderContexts = new RenderContexts();

@@ -333,2 +337,77 @@

_renderBundle( bundle, sceneRef, lightsNode ) {
const { object, camera, renderList } = bundle;
const renderContext = this._currentRenderContext;
const renderContextData = this.backend.get( renderContext );
//
const renderBundle = this._bundles.get( object, camera );
const renderBundleData = this.backend.get( renderBundle );
if ( renderBundleData.renderContexts === undefined ) renderBundleData.renderContexts = new Set();
//
const renderBundleNeedsUpdate = renderBundleData.renderContexts.has( renderContext ) === false || object.needsUpdate === true;
renderBundleData.renderContexts.add( renderContext );
if ( renderBundleNeedsUpdate ) {
if ( renderContextData.renderObjects === undefined || object.needsUpdate === true ) {
const nodeFrame = this._nodes.nodeFrame;
renderContextData.renderObjects = [];
renderContextData.renderBundles = [];
renderContextData.scene = sceneRef;
renderContextData.camera = camera;
renderContextData.renderId = nodeFrame.renderId;
renderContextData.registerBundlesPhase = true;
}
this._currentRenderBundle = renderBundle;
const opaqueObjects = renderList.opaque;
if ( opaqueObjects.length > 0 ) this._renderObjects( opaqueObjects, camera, sceneRef, lightsNode );
this._currentRenderBundle = null;
//
object.needsUpdate = false;
} else {
const renderContext = this._currentRenderContext;
const renderContextData = this.backend.get( renderContext );
for ( let i = 0, l = renderContextData.renderObjects.length; i < l; i ++ ) {
const renderObject = renderContextData.renderObjects[ i ];
this._nodes.updateBefore( renderObject );
//
renderObject.object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, renderObject.object.matrixWorld );
renderObject.object.normalMatrix.getNormalMatrix( renderObject.object.modelViewMatrix );
this._nodes.updateForRender( renderObject );
this._bindings.updateForRender( renderObject );
this.backend.draw( renderObject, this.info );
}
}
}
render( scene, camera ) {

@@ -464,3 +543,2 @@

//

@@ -573,4 +651,6 @@

const transparentObjects = renderList.transparent;
const bundles = renderList.bundles;
const lightsNode = renderList.lightsNode;
if ( bundles.length > 0 ) this._renderBundles( bundles, sceneRef, lightsNode );
if ( opaqueObjects.length > 0 ) this._renderObjects( opaqueObjects, camera, sceneRef, lightsNode );

@@ -638,10 +718,2 @@ if ( transparentObjects.length > 0 ) this._renderObjects( transparentObjects, camera, sceneRef, lightsNode );

getArrayBuffer( attribute ) { // @deprecated, r155
console.warn( 'THREE.Renderer: getArrayBuffer() is deprecated. Use getArrayBufferAsync() instead.' );
return this.getArrayBufferAsync( attribute );
}
async getArrayBufferAsync( attribute ) {

@@ -883,2 +955,12 @@

if ( renderTarget !== null && this._renderTarget === null ) {
// If a color space transform or tone mapping is required,
// the clear operation clears the intermediate renderTarget texture, but does not update the screen canvas.
_quad.material.fragmentNode = this._nodes.getOutputNode( renderTarget.texture );
this._renderScene( _quad, _quad.camera, false );
}
}

@@ -1098,3 +1180,3 @@

copyTextureToTexture( position, srcTexture, dstTexture, level = 0 ) {
copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {

@@ -1104,3 +1186,3 @@ this._textures.updateTexture( srcTexture );

this.backend.copyTextureToTexture( position, srcTexture, dstTexture, level );
this.backend.copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, level );

@@ -1208,2 +1290,21 @@ }

if ( object.static === true ) {
const baseRenderList = renderList;
// replace render list
renderList = this._renderLists.get( object, camera );
renderList.begin();
baseRenderList.pushBundle( {
object,
camera,
renderList,
} );
renderList.finish();
}
const children = object.children;

@@ -1219,2 +1320,12 @@

_renderBundles( bundles, sceneRef, lightsNode ) {
for ( const bundle of bundles ) {
this._renderBundle( bundle, sceneRef, lightsNode );
}
}
_renderObjects( renderList, camera, scene, lightsNode ) {

@@ -1413,4 +1524,21 @@

if ( this._currentRenderBundle !== null && this._currentRenderBundle.needsUpdate === true ) {
const renderObjectData = this.backend.get( renderObject );
renderObjectData.bundleEncoder = undefined;
renderObjectData.lastPipelineGPU = undefined;
}
this.backend.draw( renderObject, this.info );
if ( this._currentRenderBundle !== null ) {
const renderContextData = this.backend.get( this._currentRenderContext );
renderContextData.renderObjects.push( renderObject );
}
}

@@ -1417,0 +1545,0 @@

@@ -60,2 +60,3 @@ import { LightsNode } from '../../nodes/Nodes.js';

this.transparent = [];
this.bundles = [];

@@ -75,2 +76,4 @@ this.lightsNode = new LightsNode( [] );

this.transparent.length = 0;
this.bundles.length = 0;
this.lightsArray.length = 0;

@@ -140,2 +143,8 @@

pushBundle( group ) {
this.bundles.push( group );
}
pushLight( light ) {

@@ -142,0 +151,0 @@

@@ -229,2 +229,8 @@ import ClippingContext from './ClippingContext.js';

if ( object._colorsTexture !== null ) {
cacheKey += object._colorsTexture.uuid + ',';
}
}

@@ -231,0 +237,0 @@

@@ -5,3 +5,3 @@ import { Color, Matrix3, Matrix4, Vector2, Vector3, Vector4 } from 'three';

constructor( name, value = null ) {
constructor( name, value ) {

@@ -8,0 +8,0 @@ this.name = name;

@@ -117,4 +117,24 @@ import {

function hideObject( object ) {
if ( object.isCSS2DObject ) object.element.style.display = 'none';
for ( let i = 0, l = object.children.length; i < l; i ++ ) {
hideObject( object.children[ i ] );
}
}
function renderObject( object, scene, camera ) {
if ( object.visible === false ) {
hideObject( object );
return;
}
if ( object.isCSS2DObject ) {

@@ -125,5 +145,7 @@

const visible = ( object.visible === true ) && ( _vector.z >= - 1 && _vector.z <= 1 ) && ( object.layers.test( camera.layers ) === true );
object.element.style.display = ( visible === true ) ? '' : 'none';
const visible = ( _vector.z >= - 1 && _vector.z <= 1 ) && ( object.layers.test( camera.layers ) === true );
const element = object.element;
element.style.display = visible === true ? '' : 'none';
if ( visible === true ) {

@@ -133,4 +155,2 @@

const element = object.element;
element.style.transform = 'translate(' + ( - 100 * object.center.x ) + '%,' + ( - 100 * object.center.y ) + '%)' + 'translate(' + ( _vector.x * _widthHalf + _widthHalf ) + 'px,' + ( - _vector.y * _heightHalf + _heightHalf ) + 'px)';

@@ -177,3 +197,3 @@

scene.traverse( function ( object ) {
scene.traverseVisible( function ( object ) {

@@ -180,0 +200,0 @@ if ( object.isCSS2DObject ) result.push( object );

@@ -254,9 +254,31 @@ import {

function hideObject( object ) {
if ( object.isCSS3DObject ) object.element.style.display = 'none';
for ( let i = 0, l = object.children.length; i < l; i ++ ) {
hideObject( object.children[ i ] );
}
}
function renderObject( object, scene, camera, cameraCSSMatrix ) {
if ( object.visible === false ) {
hideObject( object );
return;
}
if ( object.isCSS3DObject ) {
const visible = ( object.visible === true ) && ( object.layers.test( camera.layers ) === true );
object.element.style.display = ( visible === true ) ? '' : 'none';
const visible = ( object.layers.test( camera.layers ) === true );
const element = object.element;
element.style.display = visible === true ? '' : 'none';
if ( visible === true ) {

@@ -294,3 +316,2 @@

const element = object.element;
const cachedObject = cache.objects.get( object );

@@ -297,0 +318,0 @@

@@ -6,3 +6,3 @@ import { MathNode, GLSLNodeParser, NodeBuilder, UniformNode, vectorComponents } from '../../../nodes/Nodes.js';

import { NodeSampledTexture, NodeSampledCubeTexture } from '../../common/nodes/NodeSampledTexture.js';
import { NodeSampledTexture, NodeSampledCubeTexture, NodeSampledTexture3D } from '../../common/nodes/NodeSampledTexture.js';

@@ -31,2 +31,3 @@ import { RedFormat, RGFormat, IntType, DataTexture, RGBFormat, RGBAFormat, FloatType } from 'three';

precision highp int;
precision highp sampler3D;
precision mediump sampler2DArray;

@@ -55,4 +56,2 @@ precision lowp sampler2DShadow;

if ( node.isOutputStructVar ) return '';
return super.getPropertyName( node, shaderStage );

@@ -62,2 +61,8 @@

getOutputStructName() {
return '';
}
buildFunctionCode( shaderNode ) {

@@ -283,4 +288,2 @@

if ( variable.isOutputStructVar ) continue;
snippets.push( `${ this.getVar( variable.type, variable.name ) };` );

@@ -330,2 +333,6 @@

} else if ( uniform.type === 'texture3D' ) {
snippet = `sampler3D ${ uniform.name };`;
} else if ( uniform.type === 'buffer' ) {

@@ -768,2 +775,7 @@

} else if ( type === 'texture3D' ) {
uniformGPU = new NodeSampledTexture3D( uniformNode.name, uniformNode.node );
this.bindings[ shaderStage ].push( uniformGPU );
} else if ( type === 'buffer' ) {

@@ -770,0 +782,0 @@

@@ -86,2 +86,6 @@ import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, FloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, SRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare } from 'three';

} else if ( texture.isData3DTexture === true ) {
glTextureType = gl.TEXTURE_3D;
} else {

@@ -117,2 +121,7 @@

if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.R8;
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.R16;
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.R32UI;
if ( glType === gl.BYTE ) internalFormat = gl.R8I;
if ( glType === gl.SHORT ) internalFormat = gl.R16I;
if ( glType === gl.INT ) internalFormat = gl.R32I;

@@ -137,3 +146,9 @@ }

if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RG8;
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.RG16;
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.RG32UI;
if ( glType === gl.BYTE ) internalFormat = gl.RG8I;
if ( glType === gl.SHORT ) internalFormat = gl.RG16I;
if ( glType === gl.INT ) internalFormat = gl.RG32I;
}

@@ -146,2 +161,8 @@

if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RGB8;
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.RGB16;
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.RGB32UI;
if ( glType === gl.BYTE ) internalFormat = gl.RGB8I;
if ( glType === gl.SHORT ) internalFormat = gl.RGB16I;
if ( glType === gl.INT ) internalFormat = gl.RGB32I;
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = ( colorSpace === SRGBColorSpace && forceLinearTransfer === false ) ? gl.SRGB8 : gl.RGB8;
if ( glType === gl.UNSIGNED_SHORT_5_6_5 ) internalFormat = gl.RGB565;

@@ -158,2 +179,8 @@ if ( glType === gl.UNSIGNED_SHORT_5_5_5_1 ) internalFormat = gl.RGB5_A1;

if ( glType === gl.HALF_FLOAT ) internalFormat = gl.RGBA16F;
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = gl.RGBA8;
if ( glType === gl.UNSIGNED_SHORT ) internalFormat = gl.RGBA16;
if ( glType === gl.UNSIGNED_INT ) internalFormat = gl.RGBA32UI;
if ( glType === gl.BYTE ) internalFormat = gl.RGBA8I;
if ( glType === gl.SHORT ) internalFormat = gl.RGBA16I;
if ( glType === gl.INT ) internalFormat = gl.RGBA32I;
if ( glType === gl.UNSIGNED_BYTE ) internalFormat = ( colorSpace === SRGBColorSpace && forceLinearTransfer === false ) ? gl.SRGB8_ALPHA8 : gl.RGBA8;

@@ -294,2 +321,6 @@ if ( glType === gl.UNSIGNED_SHORT_4_4_4_4 ) internalFormat = gl.RGBA4;

} else if ( texture.isData3DTexture ) {
gl.texStorage3D( gl.TEXTURE_3D, levels, glInternalFormat, width, height, depth );
} else if ( ! texture.isVideoTexture ) {

@@ -438,2 +469,8 @@

} else if ( texture.isData3DTexture ) {
const image = options.image;
gl.texSubImage3D( gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
} else if ( texture.isVideoTexture ) {

@@ -534,3 +571,3 @@

copyTextureToTexture( position, srcTexture, dstTexture, level = 0 ) {
copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {

@@ -540,6 +577,35 @@ const { gl, backend } = this;

const width = srcTexture.image.width;
const height = srcTexture.image.height;
const { textureGPU: dstTextureGPU, glTextureType, glType, glFormat } = backend.get( dstTexture );
let width, height, minX, minY;
let dstX, dstY;
if ( srcRegion !== null ) {
width = srcRegion.max.x - srcRegion.min.x;
height = srcRegion.max.y - srcRegion.min.y;
minX = srcRegion.min.x;
minY = srcRegion.min.y;
} else {
width = srcTexture.image.width;
height = srcTexture.image.height;
minX = 0;
minY = 0;
}
if ( dstPosition !== null ) {
dstX = dstPosition.x;
dstY = dstPosition.y;
} else {
dstX = 0;
dstY = 0;
}
state.bindTexture( glTextureType, dstTextureGPU );

@@ -549,2 +615,3 @@

// parameters, make sure they are correct for the dstTexture
gl.pixelStorei( gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
gl.pixelStorei( gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );

@@ -554,5 +621,19 @@ gl.pixelStorei( gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );

const currentUnpackRowLen = gl.getParameter( gl.UNPACK_ROW_LENGTH );
const currentUnpackImageHeight = gl.getParameter( gl.UNPACK_IMAGE_HEIGHT );
const currentUnpackSkipPixels = gl.getParameter( gl.UNPACK_SKIP_PIXELS );
const currentUnpackSkipRows = gl.getParameter( gl.UNPACK_SKIP_ROWS );
const currentUnpackSkipImages = gl.getParameter( gl.UNPACK_SKIP_IMAGES );
const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
gl.pixelStorei( gl.UNPACK_ROW_LENGTH, image.width );
gl.pixelStorei( gl.UNPACK_IMAGE_HEIGHT, image.height );
gl.pixelStorei( gl.UNPACK_SKIP_PIXELS, minX );
gl.pixelStorei( gl.UNPACK_SKIP_ROWS, minY );
if ( srcTexture.isDataTexture ) {
gl.texSubImage2D( gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );
gl.texSubImage2D( gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );

@@ -563,7 +644,7 @@ } else {

gl.compressedTexSubImage2D( gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data );
gl.compressedTexSubImage2D( gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
} else {
gl.texSubImage2D( gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );
gl.texSubImage2D( gl.TEXTURE_2D, level, dstX, dstY, glFormat, glType, image );

@@ -574,2 +655,8 @@ }

gl.pixelStorei( gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
gl.pixelStorei( gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
gl.pixelStorei( gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
gl.pixelStorei( gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
gl.pixelStorei( gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
// Generate mipmaps only when copying level 0

@@ -576,0 +663,0 @@ if ( level === 0 && dstTexture.generateMipmaps ) gl.generateMipmap( gl.TEXTURE_2D );

@@ -6,3 +6,3 @@ import { NoColorSpace, FloatType } from 'three';

import NodeSampler from '../../common/nodes/NodeSampler.js';
import { NodeSampledTexture, NodeSampledCubeTexture } from '../../common/nodes/NodeSampledTexture.js';
import { NodeSampledTexture, NodeSampledCubeTexture, NodeSampledTexture3D } from '../../common/nodes/NodeSampledTexture.js';

@@ -17,3 +17,5 @@ import NodeUniformBuffer from '../../common/nodes/NodeUniformBuffer.js';

import WGSLNodeParser from './WGSLNodeParser.js';
import { GPUStorageTextureAccess } from '../utils/WebGPUConstants.js';
// GPUShaderStage is not defined in browsers not supporting WebGPU

@@ -321,3 +323,3 @@ const GPUShaderStage = self.GPUShaderStage;

if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' ) {
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {

@@ -342,2 +344,8 @@ return name;

getOutputStructName() {
return 'output';
}
_getUniformGroupCount( shaderStage ) {

@@ -365,2 +373,37 @@

getStorageAccess( node ) {
if ( node.isStorageTextureNode ) {
switch ( node.access ) {
case GPUStorageTextureAccess.ReadOnly: {
return 'read';
}
case GPUStorageTextureAccess.WriteOnly: {
return 'write';
}
default: {
return 'read_write';
}
}
} else {
// @TODO: Account for future read-only storage buffer pull request
return 'read_write';
}
}
getUniformFromNode( node, type, shaderStage, name = null ) {

@@ -377,3 +420,3 @@

if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' ) {
if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) {

@@ -384,11 +427,15 @@ let texture = null;

texture = new NodeSampledTexture( uniformNode.name, uniformNode.node );
texture = new NodeSampledTexture( uniformNode.name, uniformNode.node, node.access ? node.access : null );
} else if ( type === 'cubeTexture' ) {
texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node );
texture = new NodeSampledCubeTexture( uniformNode.name, uniformNode.node, node.access ? node.access : null );
} else if ( type === 'texture3D' ) {
texture = new NodeSampledTexture3D( uniformNode.name, uniformNode.node, node.access ? node.access : null );
}
texture.store = node.isStoreTextureNode === true;
texture.store = node.isStorageTextureNode === true;
texture.setVisibility( gpuShaderStageLib[ shaderStage ] );

@@ -465,3 +512,3 @@

return super.isReference( type ) || type === 'texture_2d' || type === 'texture_cube' || type === 'texture_depth_2d' || type === 'texture_storage_2d';
return super.isReference( type ) || type === 'texture_2d' || type === 'texture_cube' || type === 'texture_depth_2d' || type === 'texture_storage_2d' || type === 'texture_3d';

@@ -629,2 +676,6 @@ }

const builtins = this.getBuiltins( 'output' );
if ( builtins ) snippets.push( builtins );
return snippets.join( ',\n' );

@@ -650,2 +701,4 @@

snippets.push( `\nvar<private> output : ${ name };\n\n`);
}

@@ -747,7 +800,7 @@

if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'storageTexture' ) {
if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' || uniform.type === 'storageTexture' || uniform.type === 'texture3D' ) {
const texture = uniform.node.value;
if ( shaderStage === 'fragment' && this.isUnfilterable( texture ) === false && uniform.node.isStoreTextureNode !== true ) {
if ( shaderStage === 'fragment' && this.isUnfilterable( texture ) === false && uniform.node.isStorageTextureNode !== true ) {

@@ -784,7 +837,12 @@ if ( texture.isDepthTexture === true && texture.compareFunction !== null ) {

} else if ( uniform.node.isStoreTextureNode === true ) {
} else if ( texture.isData3DTexture === true ) {
textureType = 'texture_3d<f32>';
} else if ( uniform.node.isStorageTextureNode === true ) {
const format = getFormat( texture );
const access = this.getStorageAccess( uniform.node );
textureType = `texture_storage_2d<${ format }, write>`;
textureType = `texture_storage_2d<${ format }, ${access}>`;

@@ -791,0 +849,0 @@ } else {

@@ -65,4 +65,5 @@ import {

const format = this.backend.get( binding.texture ).texture.format;
const access = binding.access;
bindingGPU.storageTexture = { format }; // GPUStorageTextureBindingLayout
bindingGPU.storageTexture = { format, access }; // GPUStorageTextureBindingLayout

@@ -107,2 +108,6 @@ } else if ( binding.isSampledTexture ) {

} else if ( binding.isSampledTexture3D ) {
texture.viewDimension = GPUTextureViewDimension.ThreeD;
}

@@ -219,2 +224,6 @@

} else if ( binding.isSampledTexture3D ) {
dimensionViewGPU = GPUTextureViewDimension.ThreeD;
} else if ( binding.texture.isDataArrayTexture ) {

@@ -221,0 +230,0 @@

@@ -272,2 +272,8 @@ export const GPUPrimitiveTopology = {

export const GPUStorageTextureAccess = {
WriteOnly: 'write-only',
ReadOnly: 'read-only',
ReadWrite: 'read-write',
};
export const GPUSamplerBindingType = {

@@ -274,0 +280,0 @@ Filtering: 'filtering',

@@ -26,2 +26,23 @@ import { BlendColorFactor, OneMinusBlendColorFactor, } from '../../common/Constants.js';

_getSampleCount( renderObjectContext ) {
let sampleCount = this.backend.utils.getSampleCount( renderObjectContext );
if ( sampleCount > 1 ) {
// WebGPU only supports power-of-two sample counts and 2 is not a valid value
sampleCount = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
if ( sampleCount === 2 ) {
sampleCount = 4;
}
}
return sampleCount;
}
createRenderPipeline( renderObject, promises ) {

@@ -106,18 +127,7 @@

const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderObject.context );
let sampleCount = utils.getSampleCount( renderObject.context );
if ( sampleCount > 1 ) {
const sampleCount = this._getSampleCount( renderObject.context );
// WebGPU only supports power-of-two sample counts and 2 is not a valid value
sampleCount = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
if ( sampleCount === 2 ) {
sampleCount = 4;
}
}
const pipelineDescriptor = {
label: 'renderPipeline',
vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),

@@ -167,2 +177,31 @@ fragment: Object.assign( {}, fragmentModule, { targets } ),

createBundleEncoder( renderContext, renderObject ) {
const backend = this.backend;
const { utils, device } = backend;
const renderContextData = backend.get( renderContext );
const renderObjectData = backend.get( renderObject );
const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderContext );
const colorFormat = utils.getCurrentColorFormat( renderContext );
const sampleCount = this._getSampleCount( renderObject.context );
const descriptor = {
label: 'renderBundleEncoder',
colorFormats: [ colorFormat ],
depthStencilFormat,
sampleCount
};
const bundleEncoder = device.createRenderBundleEncoder( descriptor );
renderObjectData.bundleEncoder = bundleEncoder;
renderContextData.currentSets = { attributes: {} };
renderContextData._renderBundleViewport = renderContext.width + '_' + renderContext.height;
return bundleEncoder;
}
createComputePipeline( pipeline, bindings ) {

@@ -192,13 +231,17 @@

const blending = material.blending;
const blendSrc = material.blendSrc;
const blendDst = material.blendDst;
const blendEquation = material.blendEquation;
if ( blending === CustomBlending ) {
const blendSrcAlpha = material.blendSrcAlpha !== null ? material.blendSrcAlpha : GPUBlendFactor.One;
const blendDstAlpha = material.blendDstAlpha !== null ? material.blendDstAlpha : GPUBlendFactor.Zero;
const blendEquationAlpha = material.blendEquationAlpha !== null ? material.blendEquationAlpha : GPUBlendFactor.Add;
const blendSrcAlpha = material.blendSrcAlpha !== null ? material.blendSrcAlpha : blendSrc;
const blendDstAlpha = material.blendDstAlpha !== null ? material.blendDstAlpha : blendDst;
const blendEquationAlpha = material.blendEquationAlpha !== null ? material.blendEquationAlpha : blendEquation;
color = {
srcFactor: this._getBlendFactor( material.blendSrc ),
dstFactor: this._getBlendFactor( material.blendDst ),
operation: this._getBlendOperation( material.blendEquation )
srcFactor: this._getBlendFactor( blendSrc ),
dstFactor: this._getBlendFactor( blendDst ),
operation: this._getBlendOperation( blendEquation )
};

@@ -205,0 +248,0 @@

@@ -6,3 +6,3 @@ import {

import {
CubeTexture, Texture,
ByteType, ShortType, CubeTexture, Texture,
NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter,

@@ -331,7 +331,7 @@ RepeatWrapping, MirroredRepeatWrapping,

if ( texture.isDataTexture || texture.isData3DTexture ) {
if ( texture.isDataTexture ) {
this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
} else if ( texture.isDataArrayTexture ) {
} else if ( texture.isDataArrayTexture || texture.isData3DTexture ) {

@@ -918,2 +918,21 @@ for ( let i = 0; i < options.image.depth; i ++ ) {

case ByteType:
formatGPU = GPUTextureFormat.RGBA8Snorm;
break;
case ShortType:
formatGPU = GPUTextureFormat.RGBA16Sint;
break;
case UnsignedShortType:
formatGPU = GPUTextureFormat.RGBA16Uint;
break;
case UnsignedIntType:
formatGPU = GPUTextureFormat.RGBA32Uint;
break;
case IntType:
formatGPU = GPUTextureFormat.RGBA32Sint;
break;
case UnsignedByteType:

@@ -957,2 +976,22 @@ formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;

case ByteType:
formatGPU = GPUTextureFormat.R8Snorm;
break;
case ShortType:
formatGPU = GPUTextureFormat.R16Sint;
break;
case UnsignedShortType:
formatGPU = GPUTextureFormat.R16Uint;
break;
case UnsignedIntType:
formatGPU = GPUTextureFormat.R32Uint;
break;
case IntType:
formatGPU = GPUTextureFormat.R32Sint;
break;
case UnsignedByteType:

@@ -981,2 +1020,22 @@ formatGPU = GPUTextureFormat.R8Unorm;

case ByteType:
formatGPU = GPUTextureFormat.RG8Snorm;
break;
case ShortType:
formatGPU = GPUTextureFormat.RG16Sint;
break;
case UnsignedShortType:
formatGPU = GPUTextureFormat.RG16Uint;
break;
case UnsignedIntType:
formatGPU = GPUTextureFormat.RG32Uint;
break;
case IntType:
formatGPU = GPUTextureFormat.RG32Sint;
break;
case UnsignedByteType:

@@ -983,0 +1042,0 @@ formatGPU = GPUTextureFormat.RG8Unorm;

@@ -456,2 +456,9 @@ /*// debugger tools

if ( renderContextData.renderBundles !== undefined && renderContextData.renderBundles.length > 0 ) {
renderContextData.registerBundlesPhase = false;
renderContextData.currentPass.executeBundles( renderContextData.renderBundles );
}
if ( occlusionQueryCount > renderContextData.occlusionQueryIndex ) {

@@ -795,6 +802,19 @@

const renderObjectData = this.get( renderObject );
const { bundleEncoder, renderBundle, lastPipelineGPU } = renderObjectData;
const renderContextData = this.get( context );
if ( renderContextData.registerBundlesPhase === true && bundleEncoder !== undefined && lastPipelineGPU === pipelineGPU ) {
renderContextData.renderBundles.push( renderBundle );
return;
}
const passEncoderGPU = this.renderer._currentRenderBundle ? this.createBundleEncoder( context, renderObject ) : contextData.currentPass;
// pipeline
const passEncoderGPU = contextData.currentPass;
if ( currentSets.pipeline !== pipelineGPU ) {

@@ -910,2 +930,12 @@

if ( this.renderer._currentRenderBundle ) {
const renderBundle = passEncoderGPU.finish();
renderObjectData.lastPipelineGPU = pipelineGPU;
renderObjectData.renderBundle = renderBundle;
renderObjectData.bundleEncoder = passEncoderGPU;
}
}

@@ -1166,2 +1196,8 @@

createBundleEncoder( renderContext, renderObject ) {
return this.pipelineUtils.createBundleEncoder( renderContext, renderObject );
}
// bindings

@@ -1242,4 +1278,14 @@

copyTextureToTexture( position, srcTexture, dstTexture, level = 0 ) {
copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
let dstX = 0;
let dstY = 0;
if ( dstPosition !== null ) {
dstX = dstPosition.x;
dstY = dstPosition.y;
}
const encoder = this.device.createCommandEncoder( { label: 'copyTextureToTexture_' + srcTexture.id + '_' + dstTexture.id } );

@@ -1259,3 +1305,3 @@

mipLevel: level,
origin: { x: position.x, y: position.y, z: position.z }
origin: { x: dstX, y: dstY, z: 0 }
},

@@ -1262,0 +1308,0 @@ [

@@ -626,3 +626,3 @@ import {

tmpAttributes[ name ] = new BufferAttribute(
tmpAttributes[ name ] = new attr.constructor(
new attr.array.constructor( attr.count * attr.itemSize ),

@@ -633,11 +633,13 @@ attr.itemSize,

const morphAttr = geometry.morphAttributes[ name ];
if ( morphAttr ) {
const morphAttributes = geometry.morphAttributes[ name ];
if ( morphAttributes ) {
tmpMorphAttributes[ name ] = new BufferAttribute(
new morphAttr.array.constructor( morphAttr.count * morphAttr.itemSize ),
morphAttr.itemSize,
morphAttr.normalized
);
if ( ! tmpMorphAttributes[ name ] ) tmpMorphAttributes[ name ] = [];
morphAttributes.forEach( ( morphAttr, i ) => {
const array = new morphAttr.array.constructor( morphAttr.count * morphAttr.itemSize );
tmpMorphAttributes[ name ][ i ] = new morphAttr.constructor( array, morphAttr.itemSize, morphAttr.normalized );
} );
}

@@ -686,5 +688,5 @@

const attribute = geometry.getAttribute( name );
const morphAttr = geometry.morphAttributes[ name ];
const morphAttributes = geometry.morphAttributes[ name ];
const itemSize = attribute.itemSize;
const newarray = tmpAttributes[ name ];
const newArray = tmpAttributes[ name ];
const newMorphArrays = tmpMorphAttributes[ name ];

@@ -696,9 +698,9 @@

const setterFunc = setters[ k ];
newarray[ setterFunc ]( nextIndex, attribute[ getterFunc ]( index ) );
newArray[ setterFunc ]( nextIndex, attribute[ getterFunc ]( index ) );
if ( morphAttr ) {
if ( morphAttributes ) {
for ( let m = 0, ml = morphAttr.length; m < ml; m ++ ) {
for ( let m = 0, ml = morphAttributes.length; m < ml; m ++ ) {
newMorphArrays[ m ][ setterFunc ]( nextIndex, morphAttr[ m ][ getterFunc ]( index ) );
newMorphArrays[ m ][ setterFunc ]( nextIndex, morphAttributes[ m ][ getterFunc ]( index ) );

@@ -727,3 +729,3 @@ }

result.setAttribute( name, new BufferAttribute(
result.setAttribute( name, new tmpAttribute.constructor(
tmpAttribute.array.slice( 0, nextIndex * tmpAttribute.itemSize ),

@@ -740,3 +742,3 @@ tmpAttribute.itemSize,

result.morphAttributes[ name ][ j ] = new BufferAttribute(
result.morphAttributes[ name ][ j ] = new tmpMorphAttribute.constructor(
tmpMorphAttribute.array.slice( 0, nextIndex * tmpMorphAttribute.itemSize ),

@@ -743,0 +745,0 @@ tmpMorphAttribute.itemSize,

@@ -59,2 +59,4 @@ import Stats from '../libs/stats.module.js';

gl.deleteQuery( query );
this.activeQueries --;

@@ -61,0 +63,0 @@

// Hybrid radix sort from
// - https://gist.github.com/sciecode/93ed864dd77c5c8803c6a86698d68dab
// - https://github.com/mrdoob/three.js/pull/27202#issuecomment-1817640271
//
// expects unsigned 32b integer values
const POWER = 3;

@@ -105,7 +108,7 @@ const BIT_MAX = 32;

const p = a[ j ], t = get( p );
const p = a[ j ], t = get( p ) >>> 0;
let i = j;
while ( i > 0 ) {
while ( i > start ) {
if ( compare( get( a[ i - 1 ] ), t ) )
if ( compare( get( a[ i - 1 ] ) >>> 0, t ) )
a[ i ] = a[ -- i ];

@@ -144,3 +147,3 @@ else

for ( let j = start; j < end; j ++ )
bin[ ( get( a[ j ] ) >> shift ) & BIN_MAX ] ++;
bin[ ( get( a[ j ] ) >>> shift ) & BIN_MAX ] ++;

@@ -152,3 +155,3 @@ accumulate( bin );

for ( let j = end - 1; j >= start; j -- )
b[ start + -- bin[ ( get( a[ j ] ) >> shift ) & BIN_MAX ] ] = a[ j ];
b[ start + -- bin[ ( get( a[ j ] ) >>> shift ) & BIN_MAX ] ] = a[ j ];

@@ -155,0 +158,0 @@ if ( depth == ITERATIONS - 1 ) return;

{
"name": "super-three",
"version": "0.164.0",
"version": "0.165.0",
"description": "JavaScript 3D library",

@@ -44,3 +44,3 @@ "type": "module",

"start": "npm run dev",
"test": "npm run lint && npm run test-unit",
"test": "npm run lint && npm run test-unit && npm run test-unit-addons",
"build": "rollup -c utils/build/rollup.config.js",

@@ -62,2 +62,3 @@ "build-module": "rollup -c utils/build/rollup.config.js --configOnlyModule",

"test-unit": "qunit -r failonlyreporter -f !-webonly test/unit/three.source.unit.js",
"test-unit-addons": "qunit -r failonlyreporter -f !-webonly test/unit/three.addons.unit.js",
"test-e2e": "node test/e2e/puppeteer.js",

@@ -64,0 +65,0 @@ "test-e2e-cov": "node test/e2e/check-coverage.js",

@@ -46,3 +46,3 @@ # three.js

renderer.setSize( width, height );
renderer.setAnimationLoop( animation );
renderer.setAnimationLoop( animate );
document.body.appendChild( renderer.domElement );

@@ -52,3 +52,3 @@

function animation( time ) {
function animate( time ) {

@@ -63,3 +63,3 @@ mesh.rotation.x = time / 2000;

If everything goes well, you should see [this](https://jsfiddle.net/2nyxkmco/).
If everything goes well, you should see [this](https://jsfiddle.net/v98k6oze/).

@@ -66,0 +66,0 @@ ### Cloning this repository

@@ -7,4 +7,13 @@ import { InterpolateDiscrete } from '../../constants.js';

*/
class BooleanKeyframeTrack extends KeyframeTrack {}
class BooleanKeyframeTrack extends KeyframeTrack {
// No interpolation parameter because only InterpolateDiscrete is valid.
constructor( name, times, values ) {
super( name, times, values );
}
}
BooleanKeyframeTrack.prototype.ValueTypeName = 'bool';

@@ -11,0 +20,0 @@ BooleanKeyframeTrack.prototype.ValueBufferType = Array;

@@ -1,2 +0,1 @@

import { InterpolateLinear } from '../../constants.js';
import { KeyframeTrack } from '../KeyframeTrack.js';

@@ -20,5 +19,5 @@ import { QuaternionLinearInterpolant } from '../../math/interpolants/QuaternionLinearInterpolant.js';

// ValueBufferType is inherited
QuaternionKeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear;
// DefaultInterpolation is inherited;
QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined;
export { QuaternionKeyframeTrack };

@@ -7,4 +7,13 @@ import { InterpolateDiscrete } from '../../constants.js';

*/
class StringKeyframeTrack extends KeyframeTrack {}
class StringKeyframeTrack extends KeyframeTrack {
// No interpolation parameter because only InterpolateDiscrete is valid.
constructor( name, times, values ) {
super( name, times, values );
}
}
StringKeyframeTrack.prototype.ValueTypeName = 'string';

@@ -11,0 +20,0 @@ StringKeyframeTrack.prototype.ValueBufferType = Array;

@@ -1,2 +0,2 @@

export const REVISION = '164';
export const REVISION = '165';

@@ -3,0 +3,0 @@ export const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };

@@ -764,2 +764,4 @@ import { Quaternion } from '../math/Quaternion.js';

if ( this._colorsTexture !== null ) object.colorsTexture = this._colorsTexture.toJSON( meta );
if ( this.boundingSphere !== null ) {

@@ -766,0 +768,0 @@

@@ -104,9 +104,13 @@ import { Matrix4 } from '../math/Matrix4.js';

let propagate = true;
if ( object.layers.test( raycaster.layers ) ) {
object.raycast( raycaster, intersects );
const result = object.raycast( raycaster, intersects );
if ( result === false ) propagate = false;
}
if ( recursive === true ) {
if ( propagate === true && recursive === true ) {

@@ -113,0 +117,0 @@ const children = object.children;

@@ -151,2 +151,6 @@ import { Cache } from './Cache.js';

}, ( e ) => {
controller.error( e );
} );

@@ -153,0 +157,0 @@

class LoaderUtils {
static decodeText( array ) {
static decodeText( array ) { // @deprecated, r165
console.warn( 'THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead.' );
if ( typeof TextDecoder !== 'undefined' ) {

@@ -6,0 +8,0 @@

@@ -964,2 +964,3 @@ import {

object._matricesTexture = getTexture( data.matricesTexture.uuid );
if ( data.colorsTexture !== undefined ) object._colorsTexture = getTexture( data.colorsTexture.uuid );

@@ -966,0 +967,0 @@ break;

@@ -8,2 +8,3 @@ import { BufferAttribute } from '../core/BufferAttribute.js';

import { RGBAFormat } from '../constants.js';
import { ColorManagement } from '../math/ColorManagement.js';
import { Box3 } from '../math/Box3.js';

@@ -13,2 +14,3 @@ import { Sphere } from '../math/Sphere.js';

import { Vector3 } from '../math/Vector3.js';
import { Color } from '../math/Color.js';

@@ -76,2 +78,3 @@ function sortOpaque( a, b ) {

const _identityMatrix = /*@__PURE__*/ new Matrix4();
const _whiteColor = /*@__PURE__*/ new Color( 1, 1, 1 );
const _projScreenMatrix = /*@__PURE__*/ new Matrix4();

@@ -82,2 +85,4 @@ const _frustum = /*@__PURE__*/ new Frustum();

const _vector = /*@__PURE__*/ new Vector3();
const _forward = /*@__PURE__*/ new Vector3();
const _temp = /*@__PURE__*/ new Vector3();
const _renderList = /*@__PURE__*/ new MultiDrawRenderList();

@@ -167,2 +172,5 @@ const _mesh = /*@__PURE__*/ new Mesh();

// Local color per geometry by using data texture
this._colorsTexture = null;
}

@@ -190,2 +198,16 @@

_initColorsTexture() {
let size = Math.sqrt( this._maxGeometryCount );
size = Math.ceil( size );
// 4 floats per RGBA pixel initialized to white
const colorsArray = new Float32Array( size * size * 4 ).fill( 1 );
const colorsTexture = new DataTexture( colorsArray, size, size, RGBAFormat, FloatType );
colorsTexture.colorSpace = ColorManagement.workingColorSpace;
this._colorsTexture = colorsTexture;
}
_initializeGeometry( reference ) {

@@ -424,2 +446,3 @@

const matricesArray = this._matricesTexture.image.data;
const colorsTexture = this._colorsTexture;

@@ -438,2 +461,10 @@ // push new visibility states

// initialize the color to white
if ( colorsTexture !== null ) {
_whiteColor.toArray( colorsTexture.image.data, geometryId * 4 );
colorsTexture.needsUpdate = true;
}
// add the reserved range and draw range objects

@@ -757,2 +788,45 @@ reservedRanges.push( reservedRange );

setColorAt( geometryId, color ) {
if ( this._colorsTexture === null ) {
this._initColorsTexture();
}
// @TODO: Map geometryId to index of the arrays because
// optimize() can make geometryId mismatch the index
const active = this._active;
const colorsTexture = this._colorsTexture;
const colorsArray = this._colorsTexture.image.data;
const geometryCount = this._geometryCount;
if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
return this;
}
color.toArray( colorsArray, geometryId * 4 );
colorsTexture.needsUpdate = true;
return this;
}
getColorAt( geometryId, color ) {
const active = this._active;
const colorsArray = this._colorsTexture.image.data;
const geometryCount = this._geometryCount;
if ( geometryId >= geometryCount || active[ geometryId ] === false ) {
return null;
}
return color.fromArray( colorsArray, geometryId * 4 );
}
setVisibleAt( geometryId, value ) {

@@ -898,2 +972,9 @@

if ( this._colorsTexture !== null ) {
this._colorsTexture = source._colorsTexture.clone();
this._colorsTexture.image.data = this._colorsTexture.image.slice();
}
return this;

@@ -910,2 +991,10 @@

this._matricesTexture = null;
if ( this._colorsTexture !== null ) {
this._colorsTexture.dispose();
this._colorsTexture = null;
}
return this;

@@ -956,2 +1045,3 @@

_vector.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _invMatrixWorld );
_forward.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ).transformDirection( _invMatrixWorld );

@@ -977,3 +1067,3 @@ for ( let i = 0, l = visibility.length; i < l; i ++ ) {

// get the distance from camera used for sorting
const z = _vector.distanceTo( _sphere.center );
const z = _temp.subVectors( _sphere.center, _vector ).dot( _forward );
_renderList.push( drawRanges[ i ], z );

@@ -980,0 +1070,0 @@

@@ -19,2 +19,17 @@ export default /* glsl */`

#endif
#ifdef USE_BATCHING_COLOR
uniform sampler2D batchingColorTexture;
vec3 getBatchingColor( const in float i ) {
int size = textureSize( batchingColorTexture, 0 ).x;
int j = int( i );
int x = j % size;
int y = j / size;
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
}
#endif
`;

@@ -6,3 +6,3 @@ export default /* glsl */`

#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )

@@ -9,0 +9,0 @@ varying vec3 vColor;

@@ -6,3 +6,3 @@ export default /* glsl */`

#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )

@@ -24,2 +24,10 @@ vColor = vec3( 1.0 );

#endif
#ifdef USE_BATCHING_COLOR
vec3 batchingColor = getBatchingColor( batchId );
vColor.xyz *= batchingColor.xyz;
#endif
`;

@@ -58,29 +58,15 @@ export default /* glsl */`

#if defined ( LEGACY_LIGHTS )
// based upon Frostbite 3 Moving to Physically-based Rendering
// page 32, equation 26: E[window1]
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
if ( cutoffDistance > 0.0 ) {
return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
}
}
return 1.0;
return distanceFalloff;
#else
// based upon Frostbite 3 Moving to Physically-based Rendering
// page 32, equation 26: E[window1]
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
if ( cutoffDistance > 0.0 ) {
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
}
return distanceFalloff;
#endif
}

@@ -87,0 +73,0 @@

export default /* glsl */`
#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
#if defined( USE_MORPHCOLORS )

@@ -4,0 +4,0 @@ // morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:

export default /* glsl */`
#ifdef USE_INSTANCING_MORPH
float morphTargetInfluences[MORPHTARGETS_COUNT];
float morphTargetInfluences[ MORPHTARGETS_COUNT ];

@@ -6,0 +6,0 @@ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;

@@ -9,20 +9,9 @@ export default /* glsl */`

#ifdef MORPHTARGETS_TEXTURE
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
}
}
#else
objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
#endif
#endif
`;

@@ -7,42 +7,21 @@ export default /* glsl */`

uniform float morphTargetBaseInfluence;
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
#endif
#ifdef MORPHTARGETS_TEXTURE
uniform sampler2DArray morphTargetsTexture;
uniform ivec2 morphTargetsTextureSize;
#ifndef USE_INSTANCING_MORPH
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
int y = texelIndex / morphTargetsTextureSize.x;
int x = texelIndex - y * morphTargetsTextureSize.x;
#endif
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
uniform sampler2DArray morphTargetsTexture;
uniform ivec2 morphTargetsTextureSize;
}
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
int y = texelIndex / morphTargetsTextureSize.x;
int x = texelIndex - y * morphTargetsTextureSize.x;
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
#else
#ifndef USE_MORPHNORMALS
uniform float morphTargetInfluences[ 8 ];
#else
uniform float morphTargetInfluences[ 4 ];
#endif
#endif
#endif
`;

@@ -9,29 +9,9 @@ export default /* glsl */`

#ifdef MORPHTARGETS_TEXTURE
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
}
}
#else
transformed += morphTarget0 * morphTargetInfluences[ 0 ];
transformed += morphTarget1 * morphTargetInfluences[ 1 ];
transformed += morphTarget2 * morphTargetInfluences[ 2 ];
transformed += morphTarget3 * morphTargetInfluences[ 3 ];
#ifndef USE_MORPHNORMALS
transformed += morphTarget4 * morphTargetInfluences[ 4 ];
transformed += morphTarget5 * morphTargetInfluences[ 5 ];
transformed += morphTarget6 * morphTargetInfluences[ 6 ];
transformed += morphTarget7 * morphTargetInfluences[ 7 ];
#endif
#endif
#endif
`;

@@ -74,2 +74,8 @@ import { BackSide, FrontSide, CubeUVReflectionMapping, SRGBTransfer } from '../../constants.js';

// buffers might not be writable which is required to ensure a correct clear
state.buffers.depth.setTest( true );
state.buffers.depth.setMask( true );
state.buffers.color.setMask( true );
renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );

@@ -76,0 +82,0 @@

@@ -0,1 +1,3 @@

import { warnOnce } from '../../utils.js';
function WebGLExtensions( gl ) {

@@ -69,3 +71,3 @@

console.warn( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );
warnOnce( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );

@@ -72,0 +74,0 @@ }

@@ -208,3 +208,3 @@ import { Color } from '../../math/Color.js';

function setup( lights, useLegacyLights ) {
function setup( lights ) {

@@ -232,5 +232,2 @@ let r = 0, g = 0, b = 0;

// artist-friendly light intensity scaling factor
const scaleFactor = ( useLegacyLights === true ) ? Math.PI : 1;
for ( let i = 0, l = lights.length; i < l; i ++ ) {

@@ -248,5 +245,5 @@

r += color.r * intensity * scaleFactor;
g += color.g * intensity * scaleFactor;
b += color.b * intensity * scaleFactor;
r += color.r * intensity;
g += color.g * intensity;
b += color.b * intensity;

@@ -267,3 +264,3 @@ } else if ( light.isLightProbe ) {

uniforms.color.copy( light.color ).multiplyScalar( light.intensity * scaleFactor );
uniforms.color.copy( light.color ).multiplyScalar( light.intensity );

@@ -299,3 +296,3 @@ if ( light.castShadow ) {

uniforms.color.copy( color ).multiplyScalar( intensity * scaleFactor );
uniforms.color.copy( color ).multiplyScalar( intensity );
uniforms.distance = distance;

@@ -361,3 +358,3 @@

uniforms.color.copy( light.color ).multiplyScalar( light.intensity * scaleFactor );
uniforms.color.copy( light.color ).multiplyScalar( light.intensity );
uniforms.distance = light.distance;

@@ -395,4 +392,4 @@ uniforms.decay = light.decay;

uniforms.skyColor.copy( light.color ).multiplyScalar( intensity * scaleFactor );
uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity * scaleFactor );
uniforms.skyColor.copy( light.color ).multiplyScalar( intensity );
uniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity );

@@ -399,0 +396,0 @@ state.hemi[ hemiLength ] = uniforms;

@@ -252,8 +252,4 @@ import { BackSide } from '../../constants.js';

uniforms.lightMap.value = material.lightMap;
uniforms.lightMapIntensity.value = material.lightMapIntensity;
// artist-friendly light intensity scaling factor
const scaleFactor = ( renderer._useLegacyLights === true ) ? Math.PI : 1;
uniforms.lightMapIntensity.value = material.lightMapIntensity * scaleFactor;
refreshTransformUniform( material.lightMap, uniforms.lightMapTransform );

@@ -260,0 +256,0 @@

@@ -15,4 +15,3 @@ import { FloatType } from '../../constants.js';

// instead of using attributes, the WebGL 2 code path encodes morph targets
// into an array of data textures. Each layer represents a single morph target.
// the following encodes morph targets into an array of data textures. Each layer represents a single morph target.

@@ -19,0 +18,0 @@ const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;

@@ -527,2 +527,3 @@ import { WebGLUniforms } from './WebGLUniforms.js';

parameters.batching ? '#define USE_BATCHING' : '',
parameters.batchingColor ? '#define USE_BATCHING_COLOR' : '',
parameters.instancing ? '#define USE_INSTANCING' : '',

@@ -624,3 +625,2 @@ parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '',

( parameters.morphColors ) ? '#define USE_MORPHCOLORS' : '',
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE' : '',
( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_TEXTURE_STRIDE ' + parameters.morphTextureStride : '',

@@ -638,4 +638,2 @@ ( parameters.morphTargetsCount > 0 ) ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '',

parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',

@@ -707,27 +705,2 @@

'#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )',
' attribute vec3 morphTarget0;',
' attribute vec3 morphTarget1;',
' attribute vec3 morphTarget2;',
' attribute vec3 morphTarget3;',
' #ifdef USE_MORPHNORMALS',
' attribute vec3 morphNormal0;',
' attribute vec3 morphNormal1;',
' attribute vec3 morphNormal2;',
' attribute vec3 morphNormal3;',
' #else',
' attribute vec3 morphTarget4;',
' attribute vec3 morphTarget5;',
' attribute vec3 morphTarget6;',
' attribute vec3 morphTarget7;',
' #endif',
'#endif',
'#ifdef USE_SKINNING',

@@ -808,3 +781,3 @@

parameters.vertexTangents && parameters.flatShading === false ? '#define USE_TANGENT' : '',
parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '',
parameters.vertexColors || parameters.instancingColor || parameters.batchingColor ? '#define USE_COLOR' : '',
parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '',

@@ -831,4 +804,2 @@ parameters.vertexUv1s ? '#define USE_UV1' : '',

parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',
parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',

@@ -835,0 +806,0 @@

@@ -197,2 +197,3 @@ import { BackSide, DoubleSide, CubeUVReflectionMapping, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping, NormalBlending, LinearSRGBColorSpace, SRGBTransfer } from '../../constants.js';

batching: IS_BATCHEDMESH,
batchingColor: IS_BATCHEDMESH && object._colorsTexture !== null,
instancing: IS_INSTANCEDMESH,

@@ -343,3 +344,2 @@ instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,

toneMapping: toneMapping,
useLegacyLights: renderer._useLegacyLights,

@@ -518,2 +518,4 @@ decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.map.colorSpace ) === SRGBTransfer ),

_programLayers.enable( 20 );
if ( parameters.batchingColor )
_programLayers.enable( 21 );

@@ -543,26 +545,24 @@ array.push( _programLayers.mask );

_programLayers.enable( 9 );
if ( parameters.useLegacyLights )
if ( parameters.doubleSided )
_programLayers.enable( 10 );
if ( parameters.doubleSided )
if ( parameters.flipSided )
_programLayers.enable( 11 );
if ( parameters.flipSided )
if ( parameters.useDepthPacking )
_programLayers.enable( 12 );
if ( parameters.useDepthPacking )
if ( parameters.dithering )
_programLayers.enable( 13 );
if ( parameters.dithering )
if ( parameters.transmission )
_programLayers.enable( 14 );
if ( parameters.transmission )
if ( parameters.sheen )
_programLayers.enable( 15 );
if ( parameters.sheen )
if ( parameters.opaque )
_programLayers.enable( 16 );
if ( parameters.opaque )
if ( parameters.pointsUvs )
_programLayers.enable( 17 );
if ( parameters.pointsUvs )
if ( parameters.decodeVideoTexture )
_programLayers.enable( 18 );
if ( parameters.decodeVideoTexture )
if ( parameters.alphaToCoverage )
_programLayers.enable( 19 );
if ( parameters.alphaToCoverage )
if ( parameters.numMultiviewViews )
_programLayers.enable( 20 );
if ( parameters.numMultiviewViews )
_programLayers.enable( 21 );

@@ -569,0 +569,0 @@ array.push( _programLayers.mask );

@@ -31,5 +31,5 @@ import { WebGLLights } from './WebGLLights.js';

function setupLights( useLegacyLights ) {
function setupLights() {
lights.setup( lightsArray, useLegacyLights );
lights.setup( lightsArray );

@@ -36,0 +36,0 @@ }

@@ -68,3 +68,3 @@ import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';

render( renderer, cameraXR ) {
getMesh( cameraXR ) {

@@ -90,6 +90,6 @@ if ( this.texture !== null ) {

renderer.render( this.mesh, cameraXR );
}
return this.mesh;
}

@@ -96,0 +96,0 @@

@@ -728,2 +728,8 @@ import { ArrayCamera } from '../../cameras/ArrayCamera.js';

this.getDepthSensingMesh = function () {
return depthSensing.getMesh( cameraXR );
};
// Animation Loop

@@ -854,4 +860,2 @@

depthSensing.render( renderer, cameraXR );
if ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );

@@ -858,0 +862,0 @@

@@ -14,6 +14,20 @@ import { ClampToEdgeWrapping } from '../constants.js';

this.layerUpdates = new Set();
}
addLayerUpdates( layerIndex ) {
this.layerUpdates.add( layerIndex );
}
clearLayerUpdates() {
this.layerUpdates.clear();
}
}
export { CompressedArrayTexture };

@@ -23,6 +23,20 @@ import { Texture } from './Texture.js';

this.layerUpdates = new Set();
}
addLayerUpdate( layerIndex ) {
this.layerUpdates.add( layerIndex );
}
clearLayerUpdates() {
this.layerUpdates.clear();
}
}
export { DataArrayTexture };

@@ -6,6 +6,4 @@ import { Texture } from './Texture.js';

constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format = DepthFormat ) {
format = format !== undefined ? format : DepthFormat;
if ( format !== DepthFormat && format !== DepthStencilFormat ) {

@@ -12,0 +10,0 @@

@@ -91,2 +91,31 @@ function arrayMin( array ) {

export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS, createCanvasElement, warnOnce };
function probeAsync( gl, sync, interval ) {
return new Promise( function ( resolve, reject ) {
function probe() {
switch ( gl.clientWaitSync( sync, gl.SYNC_FLUSH_COMMANDS_BIT, 0 ) ) {
case gl.WAIT_FAILED:
reject();
break;
case gl.TIMEOUT_EXPIRED:
setTimeout( probe, interval );
break;
default:
resolve();
}
}
setTimeout( probe, interval );
} );
}
export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS, createCanvasElement, warnOnce, probeAsync };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc