Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ycw committed May 28, 2024
2 parents 555d808 + 936402c commit a9973da
Show file tree
Hide file tree
Showing 28 changed files with 112 additions and 233 deletions.
2 changes: 1 addition & 1 deletion editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<script src="js/libs/esprima.js"></script>
<script src="js/libs/jsonlint.js"></script>

<script src="js/libs/ffmpeg.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/@ffmpeg/ffmpeg@0.11.6/dist/ffmpeg.min.js"></script>

<link rel="stylesheet" href="js/libs/codemirror/addon/dialog.css">
<link rel="stylesheet" href="js/libs/codemirror/addon/show-hint.css">
Expand Down
4 changes: 2 additions & 2 deletions editor/js/Sidebar.Geometry.CircleGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function GeometryParametersPanel( editor, object ) {
// thetaStart

const thetaStartRow = new UIRow();
const thetaStart = new UINumber( parameters.thetaStart * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
const thetaStart = new UINumber( parameters.thetaStart * THREE.MathUtils.RAD2DEG ).setUnit( '°' ).setStep( 10 ).onChange( update );

thetaStartRow.add( new UIText( strings.getKey( 'sidebar/geometry/circle_geometry/thetastart' ) ).setClass( 'Label' ) );
thetaStartRow.add( thetaStart );
Expand All @@ -46,7 +46,7 @@ function GeometryParametersPanel( editor, object ) {
// thetaLength

const thetaLengthRow = new UIRow();
const thetaLength = new UINumber( parameters.thetaLength * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
const thetaLength = new UINumber( parameters.thetaLength * THREE.MathUtils.RAD2DEG ).setUnit( '°' ).setStep( 10 ).onChange( update );

thetaLengthRow.add( new UIText( strings.getKey( 'sidebar/geometry/circle_geometry/thetalength' ) ).setClass( 'Label' ) );
thetaLengthRow.add( thetaLength );
Expand Down
4 changes: 2 additions & 2 deletions editor/js/Sidebar.Geometry.RingGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function GeometryParametersPanel( editor, object ) {
// thetaStart

const thetaStartRow = new UIRow();
const thetaStart = new UINumber( parameters.thetaStart * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
const thetaStart = new UINumber( parameters.thetaStart * THREE.MathUtils.RAD2DEG ).setUnit( '°' ).setStep( 10 ).onChange( update );

thetaStartRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/thetastart' ) ).setClass( 'Label' ) );
thetaStartRow.add( thetaStart );
Expand All @@ -66,7 +66,7 @@ function GeometryParametersPanel( editor, object ) {
// thetaLength

const thetaLengthRow = new UIRow();
const thetaLength = new UINumber( parameters.thetaLength * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
const thetaLength = new UINumber( parameters.thetaLength * THREE.MathUtils.RAD2DEG ).setUnit( '°' ).setStep( 10 ).onChange( update );

thetaLengthRow.add( new UIText( strings.getKey( 'sidebar/geometry/ring_geometry/thetalength' ) ).setClass( 'Label' ) );
thetaLengthRow.add( thetaLength );
Expand Down
2 changes: 1 addition & 1 deletion editor/js/Sidebar.Geometry.TorusGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function GeometryParametersPanel( editor, object ) {
// arc

const arcRow = new UIRow();
const arc = new UINumber( parameters.arc * THREE.MathUtils.RAD2DEG ).setStep( 10 ).onChange( update );
const arc = new UINumber( parameters.arc * THREE.MathUtils.RAD2DEG ).setUnit( '°' ).setStep( 10 ).onChange( update );

arcRow.add( new UIText( strings.getKey( 'sidebar/geometry/torus_geometry/arc' ) ).setClass( 'Label' ) );
arcRow.add( arc );
Expand Down
12 changes: 10 additions & 2 deletions editor/js/Sidebar.Project.Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,25 @@ function SidebarProjectVideo( editor ) {

// Resolution

function toDiv2() {

// Make sure dimensions are divisible by 2 (requirement of libx264)

this.setValue( 2 * Math.floor( this.getValue() / 2 ) );

}

const resolutionRow = new UIRow();
container.add( resolutionRow );

resolutionRow.add( new UIText( strings.getKey( 'sidebar/project/resolution' ) ).setClass( 'Label' ) );

const videoWidth = new UIInteger( 1024 ).setTextAlign( 'center' ).setWidth( '28px' );
const videoWidth = new UIInteger( 1024 ).setTextAlign( 'center' ).setWidth( '28px' ).setStep( 2 ).onChange( toDiv2 );
resolutionRow.add( videoWidth );

resolutionRow.add( new UIText( '×' ).setTextAlign( 'center' ).setFontSize( '12px' ).setWidth( '12px' ) );

const videoHeight = new UIInteger( 1024 ).setTextAlign( 'center' ).setWidth( '28px' );
const videoHeight = new UIInteger( 1024 ).setTextAlign( 'center' ).setWidth( '28px' ).setStep( 2 ).onChange( toDiv2 );
resolutionRow.add( videoHeight );

const videoFPS = new UIInteger( 30 ).setTextAlign( 'center' ).setWidth( '20px' );
Expand Down
2 changes: 0 additions & 2 deletions editor/js/libs/ffmpeg.min.js

This file was deleted.

1 change: 0 additions & 1 deletion editor/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ const assets = [
'./js/libs/codemirror/mode/glsl.js',

'./js/libs/esprima.js',
'./js/libs/ffmpeg.min.js',
'./js/libs/jsonlint.js',

'./js/libs/codemirror/addon/dialog.css',
Expand Down
6 changes: 3 additions & 3 deletions examples/jsm/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ export { default as ModelViewProjectionNode, modelViewProjection } from './acces
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 * 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 Texture3DNode, texture3D } from './accessors/Texture3DNode.js';
export { default as UVNode, uv } from './accessors/UVNode.js';
export * from './accessors/UVNode.js';
export { default as UserDataNode, userData } from './accessors/UserDataNode.js';

// display
Expand Down
12 changes: 6 additions & 6 deletions examples/jsm/nodes/accessors/BitangentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTa

const getBitangent = ( crossNormalTangent ) => crossNormalTangent.mul( tangentGeometry.w ).xyz;

export const bitangentGeometry = varying( getBitangent( normalGeometry.cross( tangentGeometry ) ) ).normalize();
export const bitangentLocal = varying( getBitangent( normalLocal.cross( tangentLocal ) ) ).normalize();
export const bitangentView = varying( getBitangent( normalView.cross( tangentView ) ) ).normalize();
export const bitangentWorld = varying( getBitangent( normalWorld.cross( tangentWorld ) ) ).normalize();
export const transformedBitangentView = getBitangent( transformedNormalView.cross( transformedTangentView ) ).normalize();
export const transformedBitangentWorld = transformedBitangentView.transformDirection( cameraViewMatrix ).normalize();
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' );
8 changes: 4 additions & 4 deletions examples/jsm/nodes/accessors/NormalNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { modelNormalMatrix } from './ModelNode.js';
import { vec3 } from '../shadernode/ShaderNode.js';

export const normalGeometry = /*#__PURE__*/ attribute( 'normal', 'vec3', vec3( 0, 1, 0 ) );
export const normalLocal = /*#__PURE__*/ varying( normalGeometry ).toVar( 'normalLocal' );
export const normalView = /*#__PURE__*/ varying( modelNormalMatrix.mul( normalLocal ), 'normalView' ).normalize();
export const normalWorld = /*#__PURE__*/ varying( normalView.transformDirection( cameraViewMatrix ), 'normalWorld' ).normalize();
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();
export const transformedNormalWorld = /*#__PURE__*/ transformedNormalView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedNormalWorld' );
export const transformedClearcoatNormalView = /*#__PURE__*/ property( 'vec3', 'transformedClearcoatNormalView' );
106 changes: 6 additions & 100 deletions examples/jsm/nodes/accessors/PositionNode.js
Original file line number Diff line number Diff line change
@@ -1,104 +1,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' );
33 changes: 2 additions & 31 deletions examples/jsm/nodes/accessors/ReflectVectorNode.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,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' );
8 changes: 4 additions & 4 deletions examples/jsm/nodes/accessors/TangentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const tangentGeometry = /*#__PURE__*/ tslFn( ( stack, builder ) => {

} )();

export const tangentLocal = /*#__PURE__*/ varying( tangentGeometry.xyz, 'tangentLocal' );
export const tangentView = /*#__PURE__*/ varying( modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz, 'tangentView' ).normalize();
export const tangentWorld = /*#__PURE__*/ varying( tangentView.transformDirection( cameraViewMatrix ), 'tangentWorld' ).normalize();
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();
export const transformedTangentWorld = /*#__PURE__*/ transformedTangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedTangentWorld' );
48 changes: 2 additions & 46 deletions examples/jsm/nodes/accessors/UVNode.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,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' );
6 changes: 6 additions & 0 deletions examples/jsm/nodes/core/ContextNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class ContextNode extends Node {

}

analyze( builder ) {

this.node.build( builder );

}

setup( builder ) {

const previousContext = builder.getContext();
Expand Down
8 changes: 6 additions & 2 deletions examples/jsm/nodes/core/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Node extends EventDispatcher {
this._cacheKey = null;
this._cacheKeyVersion = 0;

this.global = false;

this.isNode = true;

Object.defineProperty( this, 'id', { value: _nodeId ++ } );
Expand Down Expand Up @@ -98,7 +100,7 @@ class Node extends EventDispatcher {

isGlobal( /*builder*/ ) {

return false;
return this.global;

}

Expand Down Expand Up @@ -199,9 +201,11 @@ class Node extends EventDispatcher {

const nodeProperties = builder.getNodeProperties( this );

let index = 0;

for ( const childNode of this.getChildren() ) {

nodeProperties[ '_node' + childNode.id ] = childNode;
nodeProperties[ 'node' + index ++ ] = childNode;

}

Expand Down
Loading

0 comments on commit a9973da

Please sign in to comment.