Skip to content

Commit

Permalink
fix(types): remove use of ambient three (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored Jan 23, 2025
1 parent dd0f276 commit afe0515
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 50 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"dependencies": {
"maath": "^0.6.0",
"n8ao": "^1.9.4",
"postprocessing": "^6.36.6",
"three-stdlib": "^2.35.7"
"postprocessing": "^6.36.6"
},
"devDependencies": {
"@react-three/fiber": "9.0.0-rc.4",
Expand Down
16 changes: 7 additions & 9 deletions src/EffectComposer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TextureDataType, Group } from 'three'
import type { TextureDataType, Group, Camera, Scene } from 'three'
import { HalfFloatType, NoToneMapping } from 'three'
import {
type JSX,
Expand All @@ -22,14 +22,13 @@ import {
Pass,
EffectAttribute,
} from 'postprocessing'
import { isWebGL2Available } from 'three-stdlib'

export const EffectComposerContext = /* @__PURE__ */ createContext<{
composer: EffectComposerImpl
normalPass: NormalPass | null
downSamplingPass: DepthDownsamplingPass | null
camera: THREE.Camera
scene: THREE.Scene
camera: Camera
scene: Scene
resolutionScale?: number
}>(null!)

Expand All @@ -45,8 +44,8 @@ export type EffectComposerProps = {
multisampling?: number
frameBufferType?: TextureDataType
renderPriority?: number
camera?: THREE.Camera
scene?: THREE.Scene
camera?: Camera
scene?: Scene
}

const isConvolution = (effect: Effect): boolean =>
Expand Down Expand Up @@ -76,12 +75,11 @@ export const EffectComposer = /* @__PURE__ */ memo(
const camera = _camera || defaultCamera

const [composer, normalPass, downSamplingPass] = useMemo(() => {
const webGL2Available = isWebGL2Available()
// Initialize composer
const effectComposer = new EffectComposerImpl(gl, {
depthBuffer,
stencilBuffer,
multisampling: multisampling > 0 && webGL2Available ? multisampling : 0,
multisampling,
frameBufferType,
})

Expand All @@ -95,7 +93,7 @@ export const EffectComposer = /* @__PURE__ */ memo(
normalPass = new NormalPass(scene, camera)
normalPass.enabled = false
effectComposer.addPass(normalPass)
if (resolutionScale !== undefined && webGL2Available) {
if (resolutionScale !== undefined) {
downSamplingPass = new DepthDownsamplingPass({ normalBuffer: normalPass.texture, resolutionScale })
downSamplingPass.enabled = false
effectComposer.addPass(downSamplingPass)
Expand Down
2 changes: 1 addition & 1 deletion src/effects/ASCII.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ASCIIEffect extends Effect {
}

/** Draws the characters on a Canvas and returns a texture */
public createCharactersTexture(characters: string, font: string, fontSize: number): THREE.Texture {
public createCharactersTexture(characters: string, font: string, fontSize: number): Texture {
const canvas = document.createElement('canvas')
const SIZE = 1024
const MAX_PER_ROW = 16
Expand Down
39 changes: 1 addition & 38 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -865,11 +865,6 @@
resolved "https://registry.yarnpkg.com/@types/debounce/-/debounce-1.2.4.tgz#cb7e85d9ad5ababfac2f27183e8ac8b576b2abb3"
integrity sha512-jBqiORIzKDOToaF63Fm//haOCHuwQuLa2202RK4MozpA6lh93eCBc+/8+wZn5OzjJt3ySdc+74SXWXB55Ewtyw==

"@types/draco3d@^1.4.0":
version "1.4.2"
resolved "https://registry.yarnpkg.com/@types/draco3d/-/draco3d-1.4.2.tgz#7faccb809db2a5e19b9efb97c5f2eb9d64d527ea"
integrity sha512-goh23EGr6CLV6aKPwN1p8kBD/7tT5V/bLpToSbarKrwVejqNrspVrv8DhliteYkkhZYrlq/fwKZRRUzH4XN88w==

"@types/[email protected]", "@types/estree@^1.0.0":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50"
Expand Down Expand Up @@ -902,11 +897,6 @@
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
integrity sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==

"@types/offscreencanvas@^2019.6.4":
version "2019.7.0"
resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz#e4a932069db47bb3eabeb0b305502d01586fa90d"
integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg==

"@types/prop-types@*":
version "15.7.5"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf"
Expand Down Expand Up @@ -980,11 +970,6 @@
resolved "https://registry.yarnpkg.com/@types/webxr/-/webxr-0.5.1.tgz#4908349419104bd476a4252d04e4c3abb496748d"
integrity sha512-xlFXPfgJR5vIuDefhaHuUM9uUgvPaXB6GKdXy2gdEh8gBWQZ2ul24AJz3foUd8NNKlSTQuWYJpCb1/pL81m1KQ==

"@types/webxr@^0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@types/webxr/-/webxr-0.5.2.tgz#5d9627b0ffe223aa3b166de7112ac8a9460dc54f"
integrity sha512-szL74BnIcok9m7QwYtVmQ+EdIKwbjPANudfuvDrAF8Cljg9MKUlIoc1w5tjj9PMpeSH3U1Xnx//czQybJ0EfSw==

"@typescript-eslint/eslint-plugin@^5.59.1":
version "5.59.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.1.tgz#9b09ee1541bff1d2cebdcb87e7ce4a4003acde08"
Expand Down Expand Up @@ -1887,11 +1872,6 @@ dot-prop@^5.1.0:
dependencies:
is-obj "^2.0.0"

draco3d@^1.4.1:
version "1.5.6"
resolved "https://registry.yarnpkg.com/draco3d/-/draco3d-1.5.6.tgz#0d570a9792e3a3a9fafbfea065b692940441c626"
integrity sha512-+3NaRjWktb5r61ZFoDejlykPEFKT5N/LkbXsaddlw6xNSXBanUYpFc2AXXpbJDilPHazcSreU/DpQIaxfX0NfQ==

duplexer2@~0.1.0:
version "0.1.4"
resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1"
Expand Down Expand Up @@ -2353,7 +2333,7 @@ fastq@^1.6.0:
dependencies:
reusify "^1.0.4"

fflate@^0.6.9, fflate@~0.6.10:
fflate@~0.6.10:
version "0.6.10"
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.6.10.tgz#5f40f9659205936a2d18abf88b2e7781662b6d43"
integrity sha512-IQrh3lEPM93wVCEczc9SaAOvkmcoQn/G8Bo1e8ZPlY3X3bnAxWaBdvTdvM1hP62iZp0BXWDy4vTAy4fF0+Dlpg==
Expand Down Expand Up @@ -4465,11 +4445,6 @@ postprocessing@^6.36.6:
resolved "https://registry.yarnpkg.com/postprocessing/-/postprocessing-6.36.6.tgz#5717ee9f0af43c872e620366a181efc4b6950edd"
integrity sha512-mjJjoXbC97XMV6iQVhOZYNjD5X93o3+/zpYm9oRmsyjP3LjfwedT8PgusECTk+s5DZeZoJ8vA9htdWuH8JH+mQ==

potpack@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/potpack/-/potpack-1.0.2.tgz#23b99e64eb74f5741ffe7656b5b5c4ddce8dfc14"
integrity sha512-choctRBIV9EMT9WGAZHn3V7t0Z2pMQyl0EZE6pFc/6ml3ssw7Dlf/oAOvFwjm1HVsqfQN8GfeFyJ+d8tRzqueQ==

prelude-ls@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
Expand Down Expand Up @@ -5311,18 +5286,6 @@ text-table@^0.2.0, text-table@~0.2.0:
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==

three-stdlib@^2.35.7:
version "2.35.7"
resolved "https://registry.yarnpkg.com/three-stdlib/-/three-stdlib-2.35.7.tgz#13d345722d33328e2ffa820afadbf35a7b241c5b"
integrity sha512-k1oDqa1GYT4smhsN204DtmcQLfDuzSD4bbGmErTvUH40dpcwgBUgbwMzYYVWYB5tT7u0KBvAQpwuAPEXuwJVpQ==
dependencies:
"@types/draco3d" "^1.4.0"
"@types/offscreencanvas" "^2019.6.4"
"@types/webxr" "^0.5.2"
draco3d "^1.4.1"
fflate "^0.6.9"
potpack "^1.0.1"

three@^0.156.0:
version "0.156.1"
resolved "https://registry.yarnpkg.com/three/-/three-0.156.1.tgz#bab4fec121a5b3975eb4f4d227d9c912171eb399"
Expand Down

0 comments on commit afe0515

Please sign in to comment.