Skip to content

Commit bf1e482

Browse files
authored
fix: update three and other dependencies and fix typescript errors (#89)
* chore: update @types/three and three dependencies to latest versions * fix: update renderer type to WebGLRenderer in pcss and Pass classes * fix: simplify FBOSettings and improve useFBO function structure * fix: cast texture properties to any for compatibility in Splat functions * fix: rename depth property to depthBuffer in NORMALPROPS to follow updated useFBO params
1 parent 3d21171 commit bf1e482

File tree

8 files changed

+1550
-693
lines changed

8 files changed

+1550
-693
lines changed

.eslintrc.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
"es6": true,
66
"node": true
77
},
8-
"extends": [
9-
"prettier",
10-
"plugin:prettier/recommended",
11-
"plugin:import/errors",
12-
"plugin:import/warnings"
13-
],
8+
"extends": ["prettier", "plugin:prettier/recommended", "plugin:import/errors", "plugin:import/warnings"],
149
"plugins": ["@typescript-eslint", "prettier", "import"],
1510
"parser": "@typescript-eslint/parser",
1611
"parserOptions": {

package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@
4343
}
4444
},
4545
"scripts": {
46-
"prebuild": "rimraf dist && npm run typegen",
47-
"build": "rollup -c && npm run copy",
48-
"prepare": "npm run build && husky install",
46+
"prebuild": "rimraf dist && yarn typegen",
47+
"build": "rollup -c && yarn copy",
48+
"prepare": "yarn build && husky",
4949
"eslint": "eslint --fix .",
5050
"eslint:ci": "eslint .",
5151
"prettier": "prettier --check .",
5252
"prettier-fix": "prettier --write .",
53-
"test": "npm run eslint:ci && npm run prettier",
53+
"test": "yarn eslint:ci && yarn prettier",
5454
"typecheck": "tsc --noEmit --emitDeclarationOnly false --strict --jsx react",
5555
"typegen": "tsc --emitDeclarationOnly",
5656
"copy": "copyfiles package.json README.md LICENSE dist && json -I -f dist/package.json -e \"this.private=false; this.devDependencies=undefined; this.optionalDependencies=undefined; this.scripts=undefined; this.husky=undefined; this.prettier=undefined; this.jest=undefined; this['lint-staged']=undefined;\"",
@@ -62,12 +62,12 @@
6262
"glsl-noise": "^0.0.0"
6363
},
6464
"devDependencies": {
65-
"@babel/core": "^7.14.3",
66-
"@babel/plugin-transform-modules-commonjs": "^7.14.0",
67-
"@babel/plugin-transform-runtime": "^7.14.3",
68-
"@babel/preset-env": "^7.14.2",
69-
"@babel/preset-typescript": "^7.10.4",
70-
"@babel/runtime": "^7.11.2",
65+
"@babel/core": "^7.28.0",
66+
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
67+
"@babel/plugin-transform-runtime": "^7.28.0",
68+
"@babel/preset-env": "^7.28.0",
69+
"@babel/preset-typescript": "^7.27.1",
70+
"@babel/runtime": "^7.28.2",
7171
"@commitlint/cli": "^12.0.1",
7272
"@commitlint/config-conventional": "^12.0.1",
7373
"@rollup/plugin-babel": "^5.3.0",
@@ -84,8 +84,8 @@
8484
"@storybook/manager-webpack5": "^6.5.16",
8585
"@storybook/testing-library": "^0.0.13",
8686
"@types/jest": "^26.0.10",
87-
"@types/lodash-es": "^4.17.3",
88-
"@types/three": "^0.166.0",
87+
"@types/lodash-es": "^4.17.12",
88+
"@types/three": "^0.179.0",
8989
"@typescript-eslint/eslint-plugin": "^5.4.0",
9090
"@typescript-eslint/parser": "^5.4.0",
9191
"babel-eslint": "^10.1.0",
@@ -99,22 +99,22 @@
9999
"husky": "^6.0.0",
100100
"jest": "^26.4.1",
101101
"json": "^11.0.0",
102-
"lil-gui": "^0.19.2",
102+
"lil-gui": "^0.20.0",
103103
"prettier": "^2.4.1",
104-
"pretty-quick": "^3.1.0",
104+
"pretty-quick": "^4.2.2",
105105
"raw-loader": "^4.0.2",
106106
"react": "^18.0.0",
107107
"react-dom": "^18.0.0",
108108
"rimraf": "^3.0.2",
109109
"rollup": "^2.78.1",
110-
"rollup-plugin-glslify": "^1.3.0",
111-
"rollup-plugin-multi-input": "^1.3.1",
110+
"rollup-plugin-glslify": "^1.3.1",
111+
"rollup-plugin-multi-input": "^1.5.0",
112112
"rollup-plugin-terser": "^7.0.2",
113113
"semantic-release": "^20.1.1",
114-
"three": "^0.166.1",
114+
"three": "^0.179.1",
115115
"ts-node": "^10.9.2",
116116
"typescript": "^5.5.3",
117-
"yarn": "^1.22.17"
117+
"yarn": "^1.22.22"
118118
},
119119
"peerDependencies": {
120120
"three": ">=0.137"

src/core/Caustics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export const CausticsMaterial = shaderMaterial<CausticsMaterialType>(
252252
)
253253

254254
const NORMALPROPS = {
255-
depth: true,
255+
depthBuffer: true,
256256
minFilter: THREE.LinearFilter,
257257
magFilter: THREE.LinearFilter,
258258
type: THREE.UnsignedByteType,

src/core/Splat.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ function connect(shared: SharedState, target: TargetMesh) {
473473

474474
async function wait() {
475475
while (true) {
476-
const centerAndScaleTextureProperties = shared.gl.properties.get(shared.centerAndScaleTexture)
477-
const covAndColorTextureProperties = shared.gl.properties.get(shared.covAndColorTexture)
476+
const centerAndScaleTextureProperties = shared.gl.properties.get(shared.centerAndScaleTexture) as any
477+
const covAndColorTextureProperties = shared.gl.properties.get(shared.covAndColorTexture) as any
478478
if (
479479
centerAndScaleTextureProperties?.__webglTexture &&
480480
covAndColorTextureProperties?.__webglTexture &&
@@ -577,7 +577,7 @@ function pushDataBuffer(shared: SharedState, buffer: ArrayBufferLike, vertexCoun
577577
height = 1
578578
}
579579

580-
const centerAndScaleTextureProperties = shared.gl.properties.get(shared.centerAndScaleTexture)
580+
const centerAndScaleTextureProperties = shared.gl.properties.get(shared.centerAndScaleTexture) as any
581581
context.bindTexture(context.TEXTURE_2D, centerAndScaleTextureProperties.__webglTexture)
582582
context.texSubImage2D(
583583
context.TEXTURE_2D,
@@ -592,7 +592,7 @@ function pushDataBuffer(shared: SharedState, buffer: ArrayBufferLike, vertexCoun
592592
shared.loadedVertexCount * 4
593593
)
594594

595-
const covAndColorTextureProperties = shared.gl.properties.get(shared.covAndColorTexture)
595+
const covAndColorTextureProperties = shared.gl.properties.get(shared.covAndColorTexture) as any
596596
context.bindTexture(context.TEXTURE_2D, covAndColorTextureProperties.__webglTexture)
597597
context.texSubImage2D(
598598
context.TEXTURE_2D,

src/core/pcss.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export const pcss = ({ focus = 0, size = 25, samples = 10 }: SoftShadowsProps =
153153
'#if defined( SHADOWMAP_TYPE_PCF )',
154154
'\nreturn mix( 1.0, PCSS(shadowMap, shadowCoord), shadowIntensity );\n#if defined( SHADOWMAP_TYPE_PCF )'
155155
)
156-
return (gl: THREE.Renderer, scene: THREE.Scene, camera: THREE.Camera) => {
156+
return (gl: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera) => {
157157
THREE.ShaderChunk.shadowmap_pars_fragment = original
158158
reset(gl, scene, camera)
159159
}

src/core/useFBO.ts

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import * as THREE from 'three'
22

33
type FBOSettings = {
4-
/** Defines the count of MSAA samples. Can only be used with WebGL 2. Default: 0 */
5-
samples?: number
6-
/** If set, the scene depth will be rendered into buffer.depthTexture. Default: false */
4+
/** @deprecated use `depthBuffer` instead. If set, the scene depth will be rendered into buffer.depthTexture. Default: false */
75
depth?: boolean
86
} & THREE.RenderTargetOptions
97

@@ -13,33 +11,23 @@ function useFBO(
1311
/** Height in pixels */
1412
height = 1024,
1513
/**Settings */
16-
settings: FBOSettings = {
17-
samples: 0,
18-
depth: false,
19-
}
14+
settings?: FBOSettings
2015
): THREE.WebGLRenderTarget {
2116
var _width = width
2217
var _height = height
23-
var _settings = settings
24-
var samples = _settings.samples || 0
25-
var depth = _settings.depth
26-
var targetSettings = Object.assign({}, _settings)
27-
delete targetSettings.samples
28-
delete targetSettings.depth
29-
var target = new THREE.WebGLRenderTarget(
30-
_width,
31-
_height,
32-
Object.assign(
33-
{
34-
minFilter: THREE.LinearFilter,
35-
magFilter: THREE.LinearFilter,
36-
type: THREE.HalfFloatType,
37-
},
38-
targetSettings
39-
)
40-
)
41-
42-
if (depth) {
18+
var _settings = settings || {}
19+
const { samples = 0, depth, ...targetSettings } = _settings
20+
21+
const depthBuffer = depth ?? _settings.depthBuffer // backwards compatibility for deprecated `depth` prop
22+
23+
var target = new THREE.WebGLRenderTarget(_width, _height, {
24+
minFilter: THREE.LinearFilter,
25+
magFilter: THREE.LinearFilter,
26+
type: THREE.HalfFloatType,
27+
...targetSettings,
28+
})
29+
30+
if (depthBuffer) {
4331
target.depthTexture = new THREE.DepthTexture(_width, _height, THREE.FloatType)
4432
}
4533

src/helpers/Pass.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OrthographicCamera, PlaneGeometry, Mesh, Material, Renderer, WebGLRenderer, WebGLRenderTarget } from 'three'
1+
import { OrthographicCamera, PlaneGeometry, Mesh, Material, WebGLRenderer, WebGLRenderTarget } from 'three'
22

33
class Pass {
44
// if set to true, the pass is processed by the composer
@@ -50,7 +50,7 @@ class FullScreenQuad<TMaterial extends Material = Material> {
5050
this.mesh.geometry.dispose()
5151
}
5252

53-
public render(renderer: Renderer): void {
53+
public render(renderer: WebGLRenderer): void {
5454
renderer.render(this.mesh, this.camera)
5555
}
5656
}

0 commit comments

Comments
 (0)