Repository navigation
Conversation
mapLinear, inverseLerp, damp, pingpong, smoothstep, smootherstep, randInt, randFloat, randFloatSpread, seededRandom, generateUUID, isPowerOfTwo, ceilPowerOfTwo, floorPowerOfTwo, normalize and denormalize, following three.js r187 src/math/MathUtils.js. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 24, 2026
Contributor
Author
|
Folded into #249 so these review together; closing this one. |
doodlewind
added a commit
that referenced
this pull request
Nov 24, 2026
… buffers, Euler in all six orders, and more (#256) One commit for 21 small three.js-parity PRs by Kevin Rajan, each with its own test file: - #210 Matrix4.scale, getMaxScaleOnAxis and multiplyScalar, as three.js has them - #211 PerspectiveCamera.getFocalLength, getFilmWidth and getFilmHeight, as three.js has them - #213 a normalized BufferAttribute's getters and setters work in 0..1, as three.js does - #215 Euler.setFromQuaternion and setFromRotationMatrix in all six orders, as three.js has them - #216 Light.dispose and LightShadow.dispose, as three.js has them - #218 Box3.clampPoint, distanceToPoint, intersectsSphere and getBoundingSphere, as three.js has them - #219 Matrix4.makeBasis, extractBasis, extractRotation and makeRotationAxis, as three.js has them - #221 Int8, Uint8, Uint8Clamped, Int16 and Int32 BufferAttribute, as three.js has them - #222 Quaternion identity, conjugate, length and slerpQuaternions, as three.js has them - #223 MathUtils scalar helpers, as three.js has them - #225 MeshPhysicalMaterial.reflectivity, as three.js has it - #226 Plane, and Ray.intersectPlane / distanceToPlane / intersectsPlane, as three.js has them - #228 Sphere.set, copy, isEmpty, containsPoint, intersectsSphere, applyMatrix4 and translate, as three.js has them - #230 Object3D.copy and clone keep the source's rotation order, as three.js does - #231 InterleavedBuffer and InterleavedBufferAttribute, as three.js has them - #232 Color arithmetic and accessors, as three.js has them - #234 Matrix3, Matrix4.setFromMatrix3 and Vector3.applyNormalMatrix, as three.js has them - #235 Vector3's component-wise arithmetic, as three.js has it - #236 Layers, Object3D.layers and Raycaster.layers, as three.js has them - #238 Color sRGB conversions and the CSS color keywords, as three.js has them - #239 Vector2's component-wise arithmetic, angle and rotateAround, as three.js has them Co-authored-by: Kevin Rajan <7121943+kvnloo@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
three.js's
MathUtilshas a set of scalar helpers that three.js code reaches for all the time (mapLinear,smoothstep,damp,randFloatSpread,generateUUID, ...) (r187MathUtils.js).packages/scene'sMathUtilsonly hasDEG2RAD,RAD2DEG,degToRad,radToDeg,clamp,euclideanModuloandlerp, so snippets that use the others throwis not a function.Change:
MathUtilsinmath.tsgainsmapLinear,inverseLerp,damp,pingpong,smoothstep,smootherstep,randInt,randFloat,randFloatSpread,seededRandom(the same Mulberry32 and default seed, so seeded sequences match three.js),generateUUID(lowercase v4),isPowerOfTwo,ceilPowerOfTwo,floorPowerOfTwo,normalizeanddenormalize(same component-type scales, the same -1 clamp for signed types, and the same throw on unsupported arrays). Each one follows the r187 function body.setQuaternionFromProperEuleris left out of this PR.Test: six
node:testcases added topackages/scene/test/three-compat-mathutils.test.ts. They cover the documented values, the edge cases (emptyinverseLerprange, clamping insmoothstep/smootherstep, negativepingpong), reseedingseededRandom, the UUID format, and the normalize scales and clamp.Tier T (
packages/sceneTypeScript; no kernel, IR or export changes).Merge gate
npm run typecheck: pass, on main 6e37e8a.npm test: 206 tests, 205 pass, 0 fail, 1 skipped (the physics arena test, which needs a builtphysics_scene.wasm; main skips it too).math.tsand the new tests, 6 of the 7 tests in the file fail (TypeError: M.mapLinear is not a function, ...). At the head all 7 pass.three@0.187.0, passes unchanged (7/7).npm run test:render: not run, because no GPU was available. This PR only adds pure scalar functions that no scene calls yet, so the render output can't change.Drafted with AI assistance.
🤖 Generated with Claude Code