Skip to content

Commit

Permalink
deps from hedron globals
Browse files Browse the repository at this point in the history
  • Loading branch information
funwithtriangles committed Nov 12, 2024
1 parent 247a4e0 commit c5fea50
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"dependencies": {
"postprocessing": "^6.36.4",
"three": "^0.170.0"
"three": "^0.170.0",
"three-stdlib": "^2.34.0"
}
}
5 changes: 4 additions & 1 deletion packages/engine/src/globalVars.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import * as THREE from 'three'

import * as THREE_EXTRAS from 'three-stdlib'
import * as postprocessing from 'postprocessing'
// Third party dependencies exposed globally for sketch development
// Needs to also be exported so can be used by type definition files
export const dependencies = {
// Declaring THREE as a global var, so that sketches can use the same instance of three.js as Hedron does
// This keeps the library versions matched and also prevents strange things from happening when the library
// code is being read from different sources
THREE,
THREE_EXTRAS,
postprocessing,
}

// declare global {
Expand Down
2 changes: 2 additions & 0 deletions packages/example-project/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ declare global {
HEDRON: {
dependencies: {
THREE: typeof import('three')
THREE_EXTRAS: typeof import('three-stdlib')
postprocessing: typeof import('postprocessing')
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/example-project/sketches/hsl/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Pass, ShaderPass } from 'postprocessing'
const { THREE } = window.HEDRON.dependencies
const { THREE, postprocessing } = window.HEDRON.dependencies
const { Uniform, Texture, ShaderMaterial, Vector3 } = THREE

import fragmentShader from './hsl.glsl'

const { Pass, ShaderPass } = postprocessing

/**
* A basic post proicessing effect to adjust the hue, saturation, and lightness of the scene.
* While this could be created with existing postprocessing passes, this example demonstrates how to create a custom effect.
Expand Down
5 changes: 2 additions & 3 deletions packages/example-project/sketches/logo/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'

import './test.js'
import hedronLogoUrl from './hedron-logo.glb'
import matcapUrl from './matcap.jpg'

const { THREE } = window.HEDRON.dependencies
const { THREE, THREE_EXTRAS } = window.HEDRON.dependencies
const { GLTFLoader } = THREE_EXTRAS

const gltfLoader = new GLTFLoader()
const textureLoader = new THREE.TextureLoader()
Expand Down
39 changes: 38 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,11 @@
resolved "https://registry.yarnpkg.com/@types/doctrine/-/doctrine-0.0.9.tgz#d86a5f452a15e3e3113b99e39616a9baa0f9863f"
integrity sha512-eOIHzCUSH7SMfonMG1LsC2f8vxBFtho6NGBznK41R84YzPuvSBzrhEps33IsQiOW9+VL6NQ9DbjQJznk/S4uRA==

"@types/draco3d@^1.4.0":
version "1.4.10"
resolved "https://registry.yarnpkg.com/@types/draco3d/-/draco3d-1.4.10.tgz#63ec0ba78b30bd58203ec031f4e4f0198c596dca"
integrity sha512-AX22jp8Y7wwaBgAixaSvkoG4M/+PlAcm3Qs4OW8yT9DM4xUpWKeFhLueTAyZF39pviAdcDdeJoACapiAceqNcw==

"@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 @@ -2059,6 +2064,11 @@
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz#56e2cc26c397c038fab0e3a917a12d5c5909e901"
integrity sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==

"@types/offscreencanvas@^2019.6.4":
version "2019.7.3"
resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.7.3.tgz#90267db13f64d6e9ccb5ae3eac92786a7c77a516"
integrity sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==

"@types/path-browserify@^1.0.3":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@types/path-browserify/-/path-browserify-1.0.3.tgz#25de712d4def94b3901f033c30d3d3bd16eba8d3"
Expand Down Expand Up @@ -2135,7 +2145,7 @@
resolved "https://registry.yarnpkg.com/@types/verror/-/verror-1.10.10.tgz#d5a4b56abac169bfbc8b23d291363a682e6fa087"
integrity sha512-l4MM0Jppn18hb9xmM6wwD1uTdShpf9Pn80aXTStnK1C94gtPvJcV2FrDmbOQUAQfJ1cKZHktkQUDwEqaAKXMMg==

"@types/webxr@*":
"@types/webxr@*", "@types/webxr@^0.5.2":
version "0.5.20"
resolved "https://registry.yarnpkg.com/@types/webxr/-/webxr-0.5.20.tgz#b16b681af314ec011b2e8221b0a072d691c04953"
integrity sha512-JGpU6qiIJQKUuVSKx1GtQnHJGxRjtfGIhzO2ilq43VZZS//f1h1Sgexbdk+Lq+7569a6EYhOWrUpIruR/1Enmg==
Expand Down Expand Up @@ -3589,6 +3599,11 @@ dotenv@^9.0.2:
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-9.0.2.tgz#dacc20160935a37dea6364aa1bef819fb9b6ab05"
integrity sha512-I9OvvrHp4pIARv4+x9iuewrWycX6CcZtoAu1XrzPxc5UygMJXJZYmBsynku8IkrJwgypE5DGNjDPmPRhDCptUg==

draco3d@^1.4.1:
version "1.5.7"
resolved "https://registry.yarnpkg.com/draco3d/-/draco3d-1.5.7.tgz#94f9bce293eb8920c159dc91a4ce9124a9e899e0"
integrity sha512-m6WCKt/erDXcw+70IJXnG7M3awwQPAsZvJGX5zY7beBqpELw6RDGkYVU0W43AFxye4pDZ5i2Lbyc/NNGqwjUVQ==

duplexer@^0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6"
Expand Down Expand Up @@ -4297,6 +4312,11 @@ fdir@^6.4.2:
resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.2.tgz#ddaa7ce1831b161bc3657bb99cb36e1622702689"
integrity sha512-KnhMXsKSPZlAhp7+IjUkRZKPb4fUyccpDrdFXbi4QL1qkmFh9kVY09Yox+n4MaOb3lHZ1Tv829C3oaaXoMYPDQ==

fflate@^0.6.9:
version "0.6.10"
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.6.10.tgz#5f40f9659205936a2d18abf88b2e7781662b6d43"
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 @@ -6903,6 +6923,11 @@ postprocessing@^6.36.4:
resolved "https://registry.yarnpkg.com/postprocessing/-/postprocessing-6.36.4.tgz#f4ad199b31ed08e224bd494df730d552ed882760"
integrity sha512-3fAyBGuLNR7Rg/q+f2SNlsVCI5mDrymvxhOif3tPKEej8M38z4TvwzNZm+RNpRY2tACE7qQUNE5IHyMcqgvlAg==

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 @@ -8002,6 +8027,18 @@ thenify-all@^1.0.0:
dependencies:
any-promise "^1.0.0"

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.170.0:
version "0.170.0"
resolved "https://registry.yarnpkg.com/three/-/three-0.170.0.tgz#6087f97aab79e9e9312f9c89fcef6808642dfbb7"
Expand Down

0 comments on commit c5fea50

Please sign in to comment.