Skip to content

Commit

Permalink
fix: add FullScreenQuad directly to maintain bundle less support + Ou… (
Browse files Browse the repository at this point in the history
#77)

* fix: copy Pass/FullScreenQuad directly to maintain bundle less support + Outlines use empty {} as default input
  • Loading branch information
vis-prime authored Nov 25, 2024
1 parent b3f9eab commit 9c07f55
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 46 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
"build-storybook": "build-storybook"
},
"dependencies": {
"glsl-noise": "^0.0.0",
"three-stdlib": "^2.34.0"
"glsl-noise": "^0.0.0"
},
"devDependencies": {
"@babel/core": "^7.14.3",
Expand Down
2 changes: 1 addition & 1 deletion src/core/MeshPortalMaterial.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as THREE from 'three'
import { shaderMaterial } from './shaderMaterial'
import { version } from '../helpers/constants'
import { FullScreenQuad } from 'three-stdlib'
import { FullScreenQuad } from '../helpers/Pass'

export type PortalMaterialType = {
resolution: THREE.Vector2
Expand Down
2 changes: 1 addition & 1 deletion src/core/Outlines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function Outlines({
thickness = 0.05,
angle = Math.PI,
gl,
}: Partial<OutlinesProps>): OutlinesType {
}: Partial<OutlinesProps> = {}): OutlinesType {
const group = new THREE.Group()

let shapeProps: OutlinesProps = {
Expand Down
58 changes: 58 additions & 0 deletions src/helpers/Pass.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { OrthographicCamera, PlaneGeometry, Mesh, Material, Renderer, WebGLRenderer, WebGLRenderTarget } from 'three'

class Pass {
// if set to true, the pass is processed by the composer
public enabled = true

// if set to true, the pass indicates to swap read and write buffer after rendering
public needsSwap = true

// if set to true, the pass clears its buffer before rendering
public clear = false

// if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
public renderToScreen = false

public setSize(width: number, height: number): void {}

public render(
renderer: WebGLRenderer,
writeBuffer: WebGLRenderTarget,
readBuffer: WebGLRenderTarget,
deltaTime: number,
maskActive?: unknown
): void {
console.error('THREE.Pass: .render() must be implemented in derived pass.')
}

public dispose() {}
}

// Helper for passes that need to fill the viewport with a single quad.
class FullScreenQuad<TMaterial extends Material = Material> {
public camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)
public geometry = new PlaneGeometry(2, 2)
private mesh: Mesh<PlaneGeometry, TMaterial>

constructor(material: TMaterial) {
this.mesh = new Mesh(this.geometry, material)
}

public get material(): TMaterial {
return this.mesh.material
}

public set material(value: TMaterial) {
this.mesh.material = value
}

public dispose(): void {
this.mesh.geometry.dispose()
}

public render(renderer: Renderer): void {
renderer.render(this.mesh, this.camera)
}
}

export { Pass, FullScreenQuad }
42 changes: 0 additions & 42 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3175,11 +3175,6 @@
dependencies:
"@babel/types" "^7.3.0"

"@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/eslint-scope@^3.7.3":
version "3.7.4"
resolved "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.4.tgz"
Expand Down Expand Up @@ -3350,11 +3345,6 @@
resolved "https://registry.npmjs.org/@types/npmlog/-/npmlog-4.1.4.tgz"
integrity sha512-WKG4gTr8przEZBiJ5r3s8ZIAoMXNbOgQ+j/d5O4X3x6kZJRLNvyUJuUK/KoG3+8BaOHPhp2m7WC6JKKeovDSzQ==

"@types/offscreencanvas@^2019.6.4":
version "2019.7.0"
resolved "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz"
integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg==

"@types/parse-json@^4.0.0":
version "4.0.0"
resolved "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz"
Expand Down Expand Up @@ -3466,11 +3456,6 @@
resolved "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.1.tgz"
integrity sha512-xlFXPfgJR5vIuDefhaHuUM9uUgvPaXB6GKdXy2gdEh8gBWQZ2ul24AJz3foUd8NNKlSTQuWYJpCb1/pL81m1KQ==

"@types/webxr@^0.5.2":
version "0.5.4"
resolved "https://registry.yarnpkg.com/@types/webxr/-/webxr-0.5.4.tgz#3d55a6427f9281d456843d754c99bf7804657fe3"
integrity sha512-41gfGLTtqXZhcmoDlLDHqMJDuwAMwhHwXf9Q2job3TUBsvkNfPNI/3IWVEtLH4tyY1ElWtfwIaoNeqeEX238/Q==

"@types/yargs-parser@*":
version "21.0.0"
resolved "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz"
Expand Down Expand Up @@ -6200,11 +6185,6 @@ dotenv@^8.0.0:
resolved "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz"
integrity sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==

draco3d@^1.4.1:
version "1.5.2"
resolved "https://registry.npmjs.org/draco3d/-/draco3d-1.5.2.tgz"
integrity sha512-AeRQ25Fb29c14vpjnh167UGW0nGY0ZpEM3ld+zEXoEySlmEXcXfsCHZeTgo5qXH925V1JsdjrzasdaQ22/vXog==

duplexer2@~0.1.0:
version "0.1.4"
resolved "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz"
Expand Down Expand Up @@ -6979,11 +6959,6 @@ fetch-retry@^5.0.2:
resolved "https://registry.npmjs.org/fetch-retry/-/fetch-retry-5.0.4.tgz"
integrity sha512-LXcdgpdcVedccGg0AZqg+S8lX/FCdwXD92WNZ5k5qsb0irRhSFsBOpcJt7oevyqT2/C2nEE0zSFNdBEpj3YOSw==

fflate@^0.6.9:
version "0.6.10"
resolved "https://registry.npmjs.org/fflate/-/fflate-0.6.10.tgz"
integrity sha512-IQrh3lEPM93wVCEczc9SaAOvkmcoQn/G8Bo1e8ZPlY3X3bnAxWaBdvTdvM1hP62iZp0BXWDy4vTAy4fF0+Dlpg==

fflate@~0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.8.2.tgz#fc8631f5347812ad6028bbe4a2308b2792aa1dea"
Expand Down Expand Up @@ -11771,11 +11746,6 @@ postcss@^8.2.15:
picocolors "^1.0.0"
source-map-js "^1.0.2"

potpack@^1.0.1:
version "1.0.2"
resolved "https://registry.npmjs.org/potpack/-/potpack-1.0.2.tgz"
integrity sha512-choctRBIV9EMT9WGAZHn3V7t0Z2pMQyl0EZE6pFc/6ml3ssw7Dlf/oAOvFwjm1HVsqfQN8GfeFyJ+d8tRzqueQ==

prelude-ls@^1.2.1:
version "1.2.1"
resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz"
Expand Down Expand Up @@ -13833,18 +13803,6 @@ text-table@^0.2.0, text-table@~0.2.0:
resolved "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz"
integrity "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw=="

three-stdlib@^2.34.0:
version "2.34.0"
resolved "https://registry.yarnpkg.com/three-stdlib/-/three-stdlib-2.34.0.tgz#bc191d92037ddcc3e4d5a4ae1bd46a199a857b5b"
integrity sha512-U5qJYWgUKBFJqr1coMSbczA964uvouzBjQbtJlaI9LfMwy7hr+kc1Mfh0gqi/2872KmGu9utgff6lj8Oti8+VQ==
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.166.1:
version "0.166.1"
resolved "https://registry.yarnpkg.com/three/-/three-0.166.1.tgz#322cfc48fff4e751cd47d61fd1558c387d098d7c"
Expand Down

0 comments on commit 9c07f55

Please sign in to comment.