Skip to content

Commit

Permalink
Use more built declarations (#997)
Browse files Browse the repository at this point in the history
* Add examples

* Update patch

* Update

* Update patch

* Update patch

* Add CubeRenderTarget

* Update patch

* Add more

* Update patch

* Add more

* Update patch

* Add NodeFunction

* Update patch

* Delete examples

* Update

* Use built NodeBuilder

* Add examples

* Add ContextNode

* Update patch

* Delete examples

* Use built ContextNode

* Add examples

* Delete examples

* Add CubeRenderTarget

* Add examples

* Update patch

* Update patch

* Update patch

* Add StructTypeNode

* Update patch

* Delete examples

* Add GLSLNodeBuilder

* Add BufferAttributeNode

* Update patch

* Add isInterleavedBuffer

* Update patch

* Update patch

* Update patch

* Delete examples

* Update

* Add examples

* Update patch

* Delete examples

* Update

* Add examples

* Update patch

* Del

* Not quite ready yet

* Not ready

* Add examples

* Update patch

* Delete examples

* Update
  • Loading branch information
Methuselah96 authored May 29, 2024
1 parent 167ca24 commit 4e9491c
Show file tree
Hide file tree
Showing 13 changed files with 1,825 additions and 102 deletions.
1,830 changes: 1,731 additions & 99 deletions examples-jsm/changes.patch

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions examples-jsm/create-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,39 @@ import * as path from 'node:path';
import prettier from 'prettier';

const files = [
'nodes/accessors/BufferAttributeNode',
'nodes/accessors/TextureNode',
'nodes/code/CodeNode',
'nodes/code/FunctionNode',
'nodes/core/constants',
'nodes/core/ContextNode',
'nodes/core/InputNode',
'nodes/core/Node',
'nodes/core/NodeAttribute',
'nodes/core/NodeBuilder',
'nodes/core/NodeCache',
'nodes/core/NodeCode',
'nodes/core/NodeFrame',
'nodes/core/NodeFunction',
'nodes/core/NodeKeywords',
'nodes/core/NodeParser',
'nodes/core/NodeUniform',
'nodes/core/NodeUtils',
'nodes/core/NodeVar',
'nodes/core/NodeVarying',
'nodes/core/StackNode',
'nodes/core/StructTypeNode',
'nodes/core/UniformGroupNode',
'nodes/core/UniformNode',
'nodes/fog/FogNode',
'nodes/gpgpu/ComputeNode',
'nodes/lighting/EnvironmentNode',
'nodes/lighting/LightingContextNode',
'nodes/lighting/LightsNode',
'nodes/materials/NodeMaterial',
'nodes/shadernode/ShaderNode',
'nodes/Nodes',
'renderers/common/extras/PMREMGenerator',
'renderers/common/nodes/NodeBuilderState',
'renderers/common/nodes/NodeUniform',
'renderers/common/nodes/NodeUniformsGroup',
Expand All @@ -44,6 +54,7 @@ const files = [
'renderers/common/Color4',
'renderers/common/ComputePipeline',
'renderers/common/Constants',
'renderers/common/CubeRenderTarget',
'renderers/common/DataMap',
'renderers/common/Geometries',
'renderers/common/Info',
Expand Down
3 changes: 3 additions & 0 deletions examples-jsm/declarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as path from 'node:path';
import { argv } from 'node:process';

const files = [
'nodes/accessors/BufferAttributeNode',
'nodes/core/constants',
'nodes/core/Node',
'nodes/core/NodeAttribute',
Expand All @@ -12,6 +13,7 @@ const files = [
'nodes/core/NodeUniform',
'nodes/core/NodeVar',
'nodes/core/NodeVarying',
'nodes/core/StructTypeNode',
'nodes/core/UniformNode',
'renderers/common/nodes/NodeBuilderState',
'renderers/common/nodes/Nodes',
Expand All @@ -29,6 +31,7 @@ const files = [
'renderers/common/Color4',
'renderers/common/ComputePipeline',
'renderers/common/Constants',
'renderers/common/CubeRenderTarget',
'renderers/common/DataMap',
'renderers/common/Geometries',
'renderers/common/Info',
Expand Down
49 changes: 49 additions & 0 deletions types/three/examples/jsm/nodes/accessors/BufferAttributeNode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { BufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, TypedArray, Usage } from "three";
import InputNode from "../core/InputNode.js";
import NodeBuilder from "../core/NodeBuilder.js";
declare class BufferAttributeNode extends InputNode<TypedArray | InterleavedBuffer | BufferAttribute> {
readonly isBufferNode: true;
bufferType: string | null;
bufferStride: number;
bufferOffset: number;
usage: Usage;
instanced: boolean;
attribute: BufferAttribute | InterleavedBufferAttribute | null;
constructor(
value: TypedArray | InterleavedBuffer | BufferAttribute,
bufferType?: string | null,
bufferStride?: number,
bufferOffset?: number,
);
getNodeType(builder: NodeBuilder): string | null;
setup(builder: NodeBuilder): void;
generate(builder: NodeBuilder): string | null | undefined;
getInputType(): string;
setUsage(value: Usage): this;
setInstanced(value: boolean): this;
}
export default BufferAttributeNode;
export declare const bufferAttribute: (
array: TypedArray | InterleavedBuffer | BufferAttribute,
type?: string | null,
stride?: number,
offset?: number,
) => import("../shadernode/ShaderNode.js").ShaderNodeObject<BufferAttributeNode>;
export declare const dynamicBufferAttribute: (
array: TypedArray | InterleavedBuffer | BufferAttribute,
type?: string | null,
stride?: number,
offset?: number,
) => import("../shadernode/ShaderNode.js").ShaderNodeObject<BufferAttributeNode>;
export declare const instancedBufferAttribute: (
array: TypedArray | InterleavedBuffer | BufferAttribute,
type?: string | null,
stride?: number,
offset?: number,
) => import("../shadernode/ShaderNode.js").ShaderNodeObject<BufferAttributeNode>;
export declare const instancedDynamicBufferAttribute: (
array: TypedArray | InterleavedBuffer | BufferAttribute,
type?: string | null,
stride?: number,
offset?: number,
) => import("../shadernode/ShaderNode.js").ShaderNodeObject<BufferAttributeNode>;
2 changes: 2 additions & 0 deletions types/three/examples/jsm/nodes/core/NodeCache.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export interface ShaderStageNodeData {
code?: NodeCode | undefined;
usageCount?: number | undefined;
snippet?: string | undefined;
propertyName?: string | undefined;
propertySizeName?: string | undefined;
}
interface NodeData {
vertex?: ShaderStageNodeData | undefined;
Expand Down
5 changes: 3 additions & 2 deletions types/three/examples/jsm/nodes/core/NodeParser.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare class NodeParser {
parseFunction(): void;
import NodeFunction from "./NodeFunction.js";
declare abstract class NodeParser {
abstract parseFunction(source: string): NodeFunction;
}
export default NodeParser;
8 changes: 8 additions & 0 deletions types/three/examples/jsm/nodes/core/StructTypeNode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Node from "./Node.js";
declare class StructTypeNode extends Node {
types: string[];
readonly isStructTypeNode: true;
constructor(types: string[]);
getMemberTypes(): string[];
}
export default StructTypeNode;
5 changes: 4 additions & 1 deletion types/three/examples/jsm/nodes/core/UniformNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ declare class UniformNode<TValue> extends InputNode<TValue> {
generate(builder: NodeBuilder, output: string | null): string;
}
export default UniformNode;
export declare const uniform: <TValue>(arg1: InputNode<TValue> | TValue, arg2?: Node | string) => any;
export declare const uniform: <TValue>(
arg1: InputNode<TValue> | TValue,
arg2?: Node | string,
) => import("../shadernode/ShaderNode.js").ShaderNodeObject<UniformNode<TValue>>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { RenderTargetOptions, Texture, WebGLCubeRenderTarget, WebGLRenderer } from "three";
declare class CubeRenderTarget extends WebGLCubeRenderTarget {
readonly isCubeRenderTarget: true;
constructor(size?: number, options?: RenderTargetOptions);
fromEquirectangularTexture(renderer: WebGLRenderer, texture: Texture): this;
}
export default CubeRenderTarget;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ declare class NodeBuilderState {
vertexShader: string | null;
fragmentShader: string | null;
computeShader: string | null;
transforms: never[];
nodeAttributes: NodeAttribute[];
bindings: Binding[];
updateNodes: Node[];
Expand Down
2 changes: 2 additions & 0 deletions types/three/src/core/InterleavedBuffer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { InterleavedBufferAttribute } from "./InterleavedBufferAttribute.js";
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/InterleavedBuffer.js | Source}
*/
export class InterleavedBuffer {
readonly isInterleavedBuffer: true;

/**
* Create a new instance of {@link InterleavedBuffer}
* @param array A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray | TypedArray} with a shared buffer. Stores the geometry data.
Expand Down
2 changes: 2 additions & 0 deletions types/three/src/math/Matrix3.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export interface Matrix {
* ( class Matrix3 implements Matrix<Matrix3> )
*/
export class Matrix3 implements Matrix {
readonly isMatrix3: true;

/**
* Creates an identity matrix.
*/
Expand Down
2 changes: 2 additions & 0 deletions types/three/src/math/Matrix4.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export type Matrix4Tuple = [
* m.multiply( m3 );
*/
export class Matrix4 implements Matrix {
readonly isMatrix4: true;

/**
* Creates an identity matrix.
*/
Expand Down

0 comments on commit 4e9491c

Please sign in to comment.