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 #426

Merged
merged 71 commits into from
Jul 17, 2024
Merged

Three json #426

merged 71 commits into from
Jul 17, 2024

Conversation

Hoodgail
Copy link
Contributor

@Hoodgail Hoodgail commented Apr 26, 2023

  • Object3D

    • Scene
    • Mesh
      • InstancedMesh
    • Line
      • LineLoop
      • LineSegments
    • Skeleton
    • Camera
      • PerspectiveCamera
      • OrthographicCamera
      • CubeCamera
      • ArrayCamera
    • Group
    • Bone
    • Sprite
    • Points
    • LOD
    • Light
      • HemisphereLight
      • SpotLight
      • PointLight
      • DirectionalLight
      • AmbientLight
      • RectAreaLight
      • LightProbe
    • Audio
      • PositionalAudio
    • AudioListener
  • FogBase

    • Fog
    • FogExp2
  • Math (Core)

    • Euler
    • Quaternion
    • AnimationClip
    • KeyframeTrack
    • Matrix3
    • Matrix4
    • Vector2
    • Curve
      • CurvePath
        • Path
  • Texture

    • VideoTexture
    • DataTexture
    • CompressedTexture
    • CubeTexture
    • CanvasTexture
    • DepthTexture
  • Source

  • BufferGeometry

  • BufferAttribute

  • KeyframeTrack

    • BooleanKeyframeTrack
    • ColorKeyframeTrack
    • NumberKeyframeTrack
    • QuaternionKeyframeTrack
    • StringKeyframeTrack
    • VectorKeyframeTrack

Finalization

  • Implement the respective json interfaces to their toJSON functions.
  • Revise

@Hoodgail
Copy link
Contributor Author

@Methuselah96 What do you think of the progress so far?
let me know if how i'm doing it is good before i continue

Copy link
Contributor

@Methuselah96 Methuselah96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good overall, thanks for working on this.

types/three/src/Meta.d.ts Outdated Show resolved Hide resolved
types/three/src/animation/KeyframeTrack.d.ts Outdated Show resolved Hide resolved
Hoodgail and others added 17 commits July 11, 2024 19:09
Copy link
Contributor

@Methuselah96 Methuselah96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hoodgail Thanks for your work on this! I went ahead and did some cleanup of some of the changes, hopefully while preserving the intent of your changes. Let me know if I messed anything up and feel free to keep building on this with more PRs, I just figured this would be a good place to get some of it merged.

@Methuselah96 Methuselah96 merged commit 094445e into three-types:master Jul 17, 2024
4 checks passed
@Hoodgail
Copy link
Contributor Author

Thank you

Hoodgail added a commit to Hoodgail/three-ts-types that referenced this pull request Jul 17, 2024
Introduces the MaterialJSON format in Three.js, which extends the Material interface. The new format includes serializable properties such as color, roughness, metallic, map, normalMap, and many more. This change enables better JSON parsing and handling of material configurations for Three.js applications.

Confirmed: Types and interfaces have been updated in Object3D.d.ts and Material.d.ts. The Material class has also been updated to include toJSON methods that return MaterialJSON or MaterialJSONRoot objects based on the provided meta data.

Reference(s):
three-types#1071
three-types#1070
three-types#426
Methuselah96 added a commit that referenced this pull request Jul 18, 2024
* Update Material type definitions: Add MaterialJSON format

Introduces the MaterialJSON format in Three.js, which extends the Material interface. The new format includes serializable properties such as color, roughness, metallic, map, normalMap, and many more. This change enables better JSON parsing and handling of material configurations for Three.js applications.

Confirmed: Types and interfaces have been updated in Object3D.d.ts and Material.d.ts. The Material class has also been updated to include toJSON methods that return MaterialJSON or MaterialJSONRoot objects based on the provided meta data.

Reference(s):
#1071
#1070
#426

* Fix: Error:   240:16  error  Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead  @typescript-eslint/array-type

* ShaderMaterial & Fixes

* Add ShaderMaterialJSON to JSONMeta.materials record

* Fixes
Error:   105:28  error  Array type using 'Array<number>' is forbidden for simple types. Use 'number[]' instead          @typescript-eslint/array-type
Error:   136:19  error  Array type using 'Array<number>' is forbidden for simple types. Use 'number[]' instead          @typescript-eslint/array-type
Error:   157:22  error  Array type using 'Array<number>' is forbidden for simple types. Use 'number[]' instead          @typescript-eslint/array-type
Error:   242:14  error  Array type using 'Array<SourceJSON>' is forbidden for simple types. Use 'SourceJSON[]' instead  @typescript-eslint/array-type

* Error:   240:16  error  Array type using 'T[]' is forbidden for non-simple types. Use 'Array<T>' instead  @typescript-eslint/array-type

* Material

* ShaderMaterial

* Object3D

---------

Co-authored-by: Nathan Bierema <nbierema@gmail.com>
@mattrossman
Copy link
Contributor

@Hoodgail I traced this PR as the source of the QuaternionTuple change here

https://github.com/three-types/three-ts-types/blame/a6fadb5785285a73ccf9f9dbc8b81186c7ebfa42/types/three/src/math/Quaternion.d.ts#L14

Since fromArray is typed as

fromArray(array: QuaternionTuple, offset?: number): this;

it produces an error when provided an array that doesn't strictly have 4 elements, which is expected when passing an offset. This makes it impractical to use in common scenarios such as when the array is a Float32Array (e.g. packed buffer of multiple quaternions) or otherwise contains >4 elements.

CleanShot 2024-09-17 at 18 03 09@2x

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAKjgQwM5wCoAkBKBRPOAMyghDgHIYALKAUzooCgmBjCAO1XgEcBXZPAC8cDnQDumXAQB0ARQEw6UDsE4AKAJQt2XeDACeYOgBMAglCjIDcEWMkAxADYRBAZgBMFqwfUAObV1uOAgiIlQ6YTgAFhZ+QRkSMm9rdUNjc0trABoQsIiYTSA

Is there a reason array needs to be typed this way?

@Hoodgail
Copy link
Contributor Author

@mattrossman It looks like this was an oversight on my part. I had completely forgot about the offset argument

It should follow the same way its written in Vector3 at

fromArray(array: number[] | ArrayLike<number>, offset?: number): this;

{D400AF8F-C00C-4E49-B28E-30EA41E23447}

Will you make a pull request? or should i? My apologies !

mattrossman added a commit to mattrossman/three-ts-types that referenced this pull request Sep 18, 2024
Updates the Quaternion overloads for fromArray and toArray to align with
Vector3's implementation as discussed here:
three-types#426 (comment)
@mattrossman
Copy link
Contributor

@Hoodgail I've submitted a PR #1230, thank you for the suggested fix!

Methuselah96 pushed a commit that referenced this pull request Sep 18, 2024
* fix: Quaternion fromArray and toArray signatures

Updates the Quaternion overloads for fromArray and toArray to align with
Vector3's implementation as discussed here:
#426 (comment)

* fix: Return number[] for number[] input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants