Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three json #1071

Open
wants to merge 76 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
6e1618b
Add Skeleton.toJSON
Hoodgail Apr 11, 2023
25e7a7e
Update Skeleton.d.ts
Hoodgail Apr 11, 2023
0784960
Update Skeleton.d.ts
Hoodgail Apr 11, 2023
41584b5
Update Skeleton.d.ts
Hoodgail Apr 12, 2023
d91d774
Update Skeleton.d.ts
Hoodgail Apr 26, 2023
1c863da
BufferAttributeJSON
Hoodgail Apr 26, 2023
1d18f45
Format
Methuselah96 Apr 26, 2023
1eb2b89
KeyframeTrackJSON
Hoodgail Apr 26, 2023
7108a71
AnimationClipJSON, KeyframeTrackJSON
Hoodgail Apr 26, 2023
6037546
QuaternionTuple
Hoodgail Apr 26, 2023
10858ad
EulerTuple
Hoodgail Apr 26, 2023
060b829
Merge remote-tracking branch 'origin/patch-6' into three-json
Hoodgail Apr 26, 2023
e4b29d8
SkeletonJSON
Hoodgail Apr 26, 2023
c1c4bd8
Merge branch 'dev' into three-json
Hoodgail Apr 26, 2023
91b9834
Vector2Tuple
Hoodgail Apr 26, 2023
2d11c28
Matrix3Tuple
Hoodgail Apr 26, 2023
8210515
CurveJSON
Hoodgail Apr 26, 2023
1d2178e
Merge branch 'three-json' of https://github.com/Hoodgail/three-ts-typ…
Hoodgail Apr 26, 2023
abf9c45
SourceJSON
Hoodgail Apr 26, 2023
27cd36d
CurvePathJSON
Hoodgail Apr 26, 2023
da7bece
BufferGeometryJSON
Hoodgail Apr 26, 2023
657e668
TextureJSON
Hoodgail Apr 26, 2023
b84f11c
PathJSON
Hoodgail Apr 26, 2023
a1cfcca
Object3DJSON
Hoodgail Apr 26, 2023
3363b9e
Prettier & Lint Fixes
Hoodgail Apr 26, 2023
941c740
BoneJSON
Hoodgail Apr 27, 2023
fb652f5
GroupJSON
Hoodgail Apr 27, 2023
eae2046
MeshJSON, InstancedMeshJSON
Hoodgail Apr 27, 2023
10c1909
SkinnedMeshJSON
Hoodgail Apr 27, 2023
84e01ee
Format
Hoodgail Apr 27, 2023
4331f8e
Merge branch 'master' into three-json
Hoodgail Jul 8, 2024
8109927
Format
Hoodgail Jul 8, 2024
09a3273
Scene & Fog
Hoodgail Jul 8, 2024
3b9b810
Camera
Hoodgail Jul 8, 2024
1a7ecd0
PerspectiveCamera
Hoodgail Jul 8, 2024
354ac1e
OrthographicCamera
Hoodgail Jul 8, 2024
4bf2524
Format
Hoodgail Jul 8, 2024
947c154
Remove Meta.d.ts
Hoodgail Jul 8, 2024
b4978b8
Fix
Hoodgail Jul 8, 2024
06e4c40
Line
Hoodgail Jul 8, 2024
db45a67
LineLoop
Hoodgail Jul 8, 2024
8d33434
LineSegments
Hoodgail Jul 8, 2024
82bde3b
CubeCamera
Hoodgail Jul 8, 2024
694d5c6
Sprite
Hoodgail Jul 8, 2024
4aa0637
Points
Hoodgail Jul 8, 2024
a9bc707
BatchedMesh
Hoodgail Jul 8, 2024
b036f51
LOD
Hoodgail Jul 8, 2024
502c20d
Minor fixes
Hoodgail Jul 8, 2024
8114128
Light & LightShadow
Hoodgail Jul 8, 2024
5458ba7
HemisphereLight
Hoodgail Jul 8, 2024
1d86dd4
SpotLight
Hoodgail Jul 8, 2024
5eff13c
PointLight
Hoodgail Jul 8, 2024
450cf65
AmbientLight
Hoodgail Jul 8, 2024
ec4d19a
Light, Dir light & Light shadow
Hoodgail Jul 11, 2024
b2f0aa9
Format
Hoodgail Jul 11, 2024
406cfd3
Typo
Hoodgail Jul 11, 2024
5a6ac75
Fixx: 9:6 error All declarations in this module are exported auto…
Hoodgail Jul 11, 2024
bd56b5f
Remove package-lock.json
Methuselah96 Jul 17, 2024
68df0d4
Update Object3D
Methuselah96 Jul 17, 2024
c8ad9d3
Animation
Methuselah96 Jul 17, 2024
b342a58
Cameras
Methuselah96 Jul 17, 2024
913b0d4
BufferGeometry
Methuselah96 Jul 17, 2024
dcfbb82
Curves
Methuselah96 Jul 17, 2024
06c62f1
Lights
Methuselah96 Jul 17, 2024
cbe5d40
Objects
Methuselah96 Jul 17, 2024
7202b92
Scenes
Methuselah96 Jul 17, 2024
e780437
Textures
Methuselah96 Jul 17, 2024
e6d91e9
Add examples
Methuselah96 Jul 17, 2024
3d4d781
Update patch
Methuselah96 Jul 17, 2024
60c2a05
Delete examples
Methuselah96 Jul 17, 2024
c3ec82d
Update declaration
Methuselah96 Jul 17, 2024
9ffd147
Upgrade Object3D JSON schema for improved data structure consistency
Hoodgail Jul 17, 2024
3304943
Format
Hoodgail Jul 17, 2024
f290493
Refactor KeyframeTrack base class and related types for better type s…
Hoodgail Jul 17, 2024
f018980
Add JSONMeta to Texture.toJSON meta arg
Hoodgail Jul 17, 2024
8641cd5
Add JSONMeta to Source.toJSON meta arg
Hoodgail Jul 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions examples-jsm/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6653,10 +6653,10 @@ index e7b389cd..53406066 100644
for (const uniform of this.uniforms) {
const node = uniform.nodeUniform.node;
diff --git a/examples-jsm/examples/renderers/common/nodes/Nodes.ts b/examples-jsm/examples/renderers/common/nodes/Nodes.ts
index db035f6d..e8a2a222 100644
index db035f6d..5d4b35ba 100644
--- a/examples-jsm/examples/renderers/common/nodes/Nodes.ts
+++ b/examples-jsm/examples/renderers/common/nodes/Nodes.ts
@@ -2,10 +2,20 @@ import DataMap from '../DataMap.js';
@@ -2,10 +2,19 @@ import DataMap from '../DataMap.js';
import ChainMap from '../ChainMap.js';
import NodeBuilderState from './NodeBuilderState.js';
import {
Expand All @@ -6666,7 +6666,6 @@ index db035f6d..e8a2a222 100644
EquirectangularReflectionMapping,
EquirectangularRefractionMapping,
+ Fog,
+ FogBase,
+ FogExp2,
+ Material,
NoToneMapping,
Expand All @@ -6677,7 +6676,7 @@ index db035f6d..e8a2a222 100644
} from 'three';
import {
NodeFrame,
@@ -22,21 +32,66 @@ import {
@@ -22,21 +31,66 @@ import {
normalWorld,
pmremTexture,
viewportTopLeft,
Expand Down Expand Up @@ -6712,7 +6711,7 @@ index db035f6d..e8a2a222 100644
+interface SceneData {
+ background?: Color | Texture | CubeTexture | undefined;
+ backgroundNode?: Node | undefined;
+ fog?: FogBase | undefined;
+ fog?: Fog | FogExp2 | undefined;
+ fogNode?: Node | undefined;
+ environment?: Texture | undefined;
+ environmentNode?: Node | undefined;
Expand Down Expand Up @@ -6748,7 +6747,7 @@ index db035f6d..e8a2a222 100644
const groupNode = nodeUniformsGroup.groupNode;
const name = groupNode.name;

@@ -76,7 +131,7 @@ class Nodes extends DataMap {
@@ -76,7 +130,7 @@ class Nodes extends DataMap {

// other groups are updated just when groupNode.needsUpdate is true

Expand All @@ -6757,7 +6756,7 @@ index db035f6d..e8a2a222 100644

let groupData = this.groupsData.get(groupChain);
if (groupData === undefined) this.groupsData.set(groupChain, (groupData = {}));
@@ -90,11 +145,11 @@ class Nodes extends DataMap {
@@ -90,11 +144,11 @@ class Nodes extends DataMap {
return false;
}

Expand All @@ -6771,7 +6770,7 @@ index db035f6d..e8a2a222 100644
const renderObjectData = this.get(renderObject);

let nodeBuilderState = renderObjectData.nodeBuilderState;
@@ -131,20 +186,20 @@ class Nodes extends DataMap {
@@ -131,20 +185,20 @@ class Nodes extends DataMap {
return nodeBuilderState;
}

Expand All @@ -6797,7 +6796,7 @@ index db035f6d..e8a2a222 100644
const computeData = this.get(computeNode);

let nodeBuilderState = computeData.nodeBuilderState;
@@ -161,7 +216,7 @@ class Nodes extends DataMap {
@@ -161,7 +215,7 @@ class Nodes extends DataMap {
return nodeBuilderState;
}

Expand All @@ -6806,7 +6805,7 @@ index db035f6d..e8a2a222 100644
return new NodeBuilderState(
nodeBuilder.vertexShader,
nodeBuilder.fragmentShader,
@@ -176,20 +231,28 @@ class Nodes extends DataMap {
@@ -176,20 +230,28 @@ class Nodes extends DataMap {
);
}

Expand Down Expand Up @@ -6843,7 +6842,7 @@ index db035f6d..e8a2a222 100644
const callId = this.renderer.info.calls;

let cacheKeyData = this.callHashCache.get(chain);
@@ -215,7 +278,7 @@ class Nodes extends DataMap {
@@ -215,7 +277,7 @@ class Nodes extends DataMap {
return cacheKeyData.cacheKey;
}

Expand All @@ -6852,7 +6851,7 @@ index db035f6d..e8a2a222 100644
this.updateEnvironment(scene);
this.updateFog(scene);
this.updateBackground(scene);
@@ -225,7 +288,7 @@ class Nodes extends DataMap {
@@ -225,7 +287,7 @@ class Nodes extends DataMap {
return this.renderer.getRenderTarget() ? false : true;
}

Expand All @@ -6861,7 +6860,7 @@ index db035f6d..e8a2a222 100644
const sceneData = this.get(scene);
const background = scene.background;

@@ -234,15 +297,15 @@ class Nodes extends DataMap {
@@ -234,15 +296,15 @@ class Nodes extends DataMap {
let backgroundNode = null;

if (
Expand All @@ -6884,7 +6883,7 @@ index db035f6d..e8a2a222 100644
}

sceneData.backgroundNode = backgroundNode;
@@ -254,7 +317,7 @@ class Nodes extends DataMap {
@@ -254,7 +316,7 @@ class Nodes extends DataMap {
}
}

Expand All @@ -6893,7 +6892,7 @@ index db035f6d..e8a2a222 100644
const sceneData = this.get(scene);
const fog = scene.fog;

@@ -262,9 +325,9 @@ class Nodes extends DataMap {
@@ -262,9 +324,9 @@ class Nodes extends DataMap {
if (sceneData.fog !== fog) {
let fogNode = null;

Expand All @@ -6905,7 +6904,7 @@ index db035f6d..e8a2a222 100644
fogNode = rangeFog(
reference('color', 'color', fog),
reference('near', 'float', fog),
@@ -283,7 +346,7 @@ class Nodes extends DataMap {
@@ -283,7 +345,7 @@ class Nodes extends DataMap {
}
}

Expand All @@ -6914,7 +6913,7 @@ index db035f6d..e8a2a222 100644
const sceneData = this.get(scene);
const environment = scene.environment;

@@ -291,7 +354,7 @@ class Nodes extends DataMap {
@@ -291,7 +353,7 @@ class Nodes extends DataMap {
if (sceneData.environment !== environment) {
let environmentNode = null;

Expand All @@ -6923,7 +6922,7 @@ index db035f6d..e8a2a222 100644
environmentNode = cubeTexture(environment);
} else if (environment.isTexture === true) {
environmentNode = texture(environment);
@@ -308,7 +371,13 @@ class Nodes extends DataMap {
@@ -308,7 +370,13 @@ class Nodes extends DataMap {
}
}

Expand All @@ -6938,7 +6937,7 @@ index db035f6d..e8a2a222 100644
const nodeFrame = this.nodeFrame;
nodeFrame.renderer = renderer;
nodeFrame.scene = scene;
@@ -319,7 +388,7 @@ class Nodes extends DataMap {
@@ -319,7 +387,7 @@ class Nodes extends DataMap {
return nodeFrame;
}

Expand All @@ -6947,7 +6946,7 @@ index db035f6d..e8a2a222 100644
return this.getNodeFrame(
renderObject.renderer,
renderObject.scene,
@@ -329,8 +398,8 @@ class Nodes extends DataMap {
@@ -329,8 +397,8 @@ class Nodes extends DataMap {
);
}

Expand All @@ -6958,7 +6957,7 @@ index db035f6d..e8a2a222 100644

if (this.isToneMappingState) {
if (this.renderer.toneMappingNode) {
@@ -347,7 +416,7 @@ class Nodes extends DataMap {
@@ -347,7 +415,7 @@ class Nodes extends DataMap {
return output;
}

Expand All @@ -6967,7 +6966,7 @@ index db035f6d..e8a2a222 100644
const nodeFrame = this.getNodeFrameForRender(renderObject);
const nodeBuilder = renderObject.getNodeBuilderState();

@@ -356,7 +425,7 @@ class Nodes extends DataMap {
@@ -356,7 +424,7 @@ class Nodes extends DataMap {
}
}

Expand All @@ -6976,7 +6975,7 @@ index db035f6d..e8a2a222 100644
const nodeFrame = this.getNodeFrameForRender(renderObject);
const nodeBuilder = renderObject.getNodeBuilderState();

@@ -365,7 +434,7 @@ class Nodes extends DataMap {
@@ -365,7 +433,7 @@ class Nodes extends DataMap {
}
}

Expand All @@ -6985,7 +6984,7 @@ index db035f6d..e8a2a222 100644
const nodeFrame = this.getNodeFrame();
const nodeBuilder = this.getForCompute(computeNode);

@@ -374,7 +443,7 @@ class Nodes extends DataMap {
@@ -374,7 +442,7 @@ class Nodes extends DataMap {
}
}

Expand Down
4 changes: 2 additions & 2 deletions types/three/examples/jsm/renderers/common/nodes/Nodes.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Camera, Color, CubeTexture, FogBase, Material, Object3D, Scene, Texture } from "three";
import { Camera, Color, CubeTexture, Fog, FogExp2, Material, Object3D, Scene, Texture } from "three";
import Node from "../../../nodes/core/Node.js";
import NodeBuilder from "../../../nodes/core/NodeBuilder.js";
import UniformGroupNode from "../../../nodes/core/UniformGroupNode.js";
Expand All @@ -25,7 +25,7 @@ interface ComputeNodeData {
interface SceneData {
background?: Color | Texture | CubeTexture | undefined;
backgroundNode?: Node | undefined;
fog?: FogBase | undefined;
fog?: Fog | FogExp2 | undefined;
fogNode?: Node | undefined;
environment?: Texture | undefined;
environmentNode?: Node | undefined;
Expand Down
16 changes: 12 additions & 4 deletions types/three/src/animation/AnimationClip.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { AnimationBlendMode } from "../constants.js";
import { Vector3 } from "../math/Vector3.js";
import { Bone } from "../objects/Bone.js";
import { KeyframeTrack } from "./KeyframeTrack.js";
import { KeyframeTrack, KeyframeTrackJSON } from "./KeyframeTrack.js";

export interface AnimationClipJSON {
name: string;
duration: number;
tracks: KeyframeTrackJSON[];
uuid: string;
blendMode: AnimationBlendMode;
}

export interface MorphTarget {
name: string;
Expand Down Expand Up @@ -45,7 +53,7 @@ export class AnimationClip {
fps: number,
noLoop: boolean,
): AnimationClip[];
static parse(json: any): AnimationClip;
static parseAnimation(animation: any, bones: Bone[]): AnimationClip;
static toJSON(clip: AnimationClip): any;
static parse(json: AnimationClipJSON): AnimationClip;
static parseAnimation(animation: AnimationClipJSON, bones: Bone[]): AnimationClip;
static toJSON(clip: AnimationClip): AnimationClipJSON;
}
22 changes: 16 additions & 6 deletions types/three/src/animation/KeyframeTrack.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,30 @@ import { CubicInterpolant } from "../math/interpolants/CubicInterpolant.js";
import { DiscreteInterpolant } from "../math/interpolants/DiscreteInterpolant.js";
import { LinearInterpolant } from "../math/interpolants/LinearInterpolant.js";

export class KeyframeTrack {
export interface KeyframeTrackJSON<V, T> {
name: string;
times: number[];
values: V[];
interpolation?: InterpolationModes;
type: T;
}

export class KeyframeTrack<Value = any> {
/**
* @param name
* @param times
* @param values
* @param [interpolation=THREE.InterpolateLinear]
*/
constructor(name: string, times: ArrayLike<number>, values: ArrayLike<any>, interpolation?: InterpolationModes);
constructor(name: string, times: ArrayLike<number>, values: ArrayLike<Value>, interpolation?: InterpolationModes);

name: string;
times: Float32Array;
values: Float32Array;
values: ArrayLike<Value>;

ValueTypeName: string;
TimeBufferType: Float32Array;
ValueBufferType: Float32Array;
TimeBufferType: typeof Float32Array;
ValueBufferType: typeof Float32Array | typeof Array;

/**
* @default THREE.InterpolateLinear
Expand All @@ -43,5 +51,7 @@ export class KeyframeTrack {
optimize(): KeyframeTrack;
clone(): this;

static toJSON(track: KeyframeTrack): any;
static toJSON<Track extends KeyframeTrack>(
track: Track,
): KeyframeTrackJSON<Track extends KeyframeTrack<infer V> ? V : never, Track["ValueTypeName"]>;
}
6 changes: 3 additions & 3 deletions types/three/src/animation/tracks/BooleanKeyframeTrack.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { KeyframeTrack } from "../KeyframeTrack.js";

export class BooleanKeyframeTrack extends KeyframeTrack {
constructor(name: string, times: ArrayLike<number>, values: ArrayLike<any>);
export class BooleanKeyframeTrack extends KeyframeTrack<boolean> {
constructor(name: string, times: ArrayLike<number>, values: ArrayLike<boolean>);

/**
* @default 'bool'
*/
ValueTypeName: string;
ValueTypeName: "bool";
}
4 changes: 2 additions & 2 deletions types/three/src/animation/tracks/ColorKeyframeTrack.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { InterpolationModes } from "../../constants.js";
import { KeyframeTrack } from "../KeyframeTrack.js";

export class ColorKeyframeTrack extends KeyframeTrack {
export class ColorKeyframeTrack extends KeyframeTrack<number> {
constructor(name: string, times: ArrayLike<number>, values: ArrayLike<number>, interpolation?: InterpolationModes);

/**
* @default 'color'
*/
ValueTypeName: string;
ValueTypeName: "color";
}
4 changes: 2 additions & 2 deletions types/three/src/animation/tracks/NumberKeyframeTrack.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { InterpolationModes } from "../../constants.js";
import { KeyframeTrack } from "../KeyframeTrack.js";

export class NumberKeyframeTrack extends KeyframeTrack {
export class NumberKeyframeTrack extends KeyframeTrack<number> {
constructor(name: string, times: ArrayLike<number>, values: ArrayLike<number>, interpolation?: InterpolationModes);

/**
* @default 'number'
*/
ValueTypeName: string;
ValueTypeName: "number";
}
4 changes: 2 additions & 2 deletions types/three/src/animation/tracks/QuaternionKeyframeTrack.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { InterpolationModes } from "../../constants.js";
import { KeyframeTrack } from "../KeyframeTrack.js";

export class QuaternionKeyframeTrack extends KeyframeTrack {
export class QuaternionKeyframeTrack extends KeyframeTrack<number> {
constructor(name: string, times: ArrayLike<number>, values: ArrayLike<number>, interpolation?: InterpolationModes);

/**
* @default 'quaternion'
*/
ValueTypeName: string;
ValueTypeName: "quaternion";
}
6 changes: 3 additions & 3 deletions types/three/src/animation/tracks/StringKeyframeTrack.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { KeyframeTrack } from "../KeyframeTrack.js";

export class StringKeyframeTrack extends KeyframeTrack {
constructor(name: string, times: ArrayLike<number>, values: ArrayLike<any>);
export class StringKeyframeTrack extends KeyframeTrack<string> {
constructor(name: string, times: ArrayLike<number>, values: ArrayLike<string>);

/**
* @default 'string'
*/
ValueTypeName: string;
ValueTypeName: "string";
}
4 changes: 2 additions & 2 deletions types/three/src/animation/tracks/VectorKeyframeTrack.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { InterpolationModes } from "../../constants.js";
import { KeyframeTrack } from "../KeyframeTrack.js";

export class VectorKeyframeTrack extends KeyframeTrack {
export class VectorKeyframeTrack extends KeyframeTrack<number> {
constructor(name: string, times: ArrayLike<number>, values: ArrayLike<number>, interpolation?: InterpolationModes);

/**
* @default 'vector'
*/
ValueTypeName: string;
ValueTypeName: "vector";
}
Loading