Skip to content

Commit

Permalink
fix: compat (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored May 31, 2023
1 parent fd47a04 commit 6071171
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
26 changes: 26 additions & 0 deletions src/_polyfill/CapsuleGeometry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Path, LatheGeometry } from 'three'

class CapsuleGeometry extends LatheGeometry {
constructor(radius = 1, length = 1, capSegments = 4, radialSegments = 8) {
const path = new Path()
path.absarc(0, -length / 2, radius, Math.PI * 1.5, 0)
path.absarc(0, length / 2, radius, 0, Math.PI * 0.5)

super(path.getPoints(capSegments), radialSegments)

this.type = 'CapsuleGeometry'

this.parameters = {
radius: radius,
height: length,
capSegments: capSegments,
radialSegments: radialSegments,
}
}

static fromJSON(data) {
return new CapsuleGeometry(data.radius, data.length, data.capSegments, data.radialSegments)
}
}

export { CapsuleGeometry }
2 changes: 1 addition & 1 deletion src/animation/MMDPhysics.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
Bone,
BoxGeometry,
CapsuleGeometry,
Color,
Euler,
Matrix4,
Expand All @@ -12,6 +11,7 @@ import {
SphereGeometry,
Vector3,
} from 'three'
import { CapsuleGeometry } from '../_polyfill/CapsuleGeometry'

/**
* Dependencies
Expand Down
6 changes: 3 additions & 3 deletions src/exporters/GLTFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
RGBAFormat,
RepeatWrapping,
Scene,
Source,
Texture,
CompressedTexture,
Vector3,
PlaneGeometry,
Expand All @@ -28,7 +28,6 @@ import {
Mesh,
PerspectiveCamera,
WebGLRenderer,
Texture,
} from 'three'

let _renderer
Expand Down Expand Up @@ -797,7 +796,8 @@ class GLTFWriter {

const texture = reference.clone()

texture.source = new Source(canvas)
// TODO Use new Source() instead?
texture.source = new Texture(canvas).source
if ('colorSpace' in texture) texture.colorSpace = ''
else texture.encoding = 3000
texture.channel = (metalnessMap || roughnessMap).channel
Expand Down

0 comments on commit 6071171

Please sign in to comment.