Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/cientos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/trescientos.js"
"import": "./dist/index.js"
},
"./core": {
"types": "./dist/core/index.d.ts"
},
"./*": "./*"
},
"main": "./dist/trescientos.js",
"module": "./dist/trescientos.js",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"*.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Vector3,
} from 'three'
import { MeshSurfaceSampler } from 'three-stdlib'
import { ref } from 'vue'
import { type Ref, ref } from 'vue'
import type { InstancedMesh, Mesh, Object3DEventMap } from 'three'
import type { TresObject } from '@tresjs/core'

Expand Down Expand Up @@ -85,7 +85,9 @@ export const useSurfaceSampler = (
instanceMesh?: InstancedMesh | null,
weight?: string,
transform?: TransformFn,
) => {
): {
buffer: Ref<InterleavedBuffer>
} => {
const arr = new Float32Array(count * 16)
const buffer = ref(new InterleavedBuffer(arr, 16))

Expand Down
10 changes: 10 additions & 0 deletions packages/cientos/src/core/loaders/useTexture/component.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { LoadingManager, Texture } from 'three'
import { useTexture } from '.'
import { whenever } from '@vueuse/core'
import type { VNode } from 'vue'

const props = defineProps<{
/**
Expand All @@ -22,6 +23,15 @@ const emit = defineEmits<{
loaded: [result: Texture]
error: [error: unknown]
}>()

defineSlots<{
default?: (props: {
state: Texture | null
isLoading: boolean
error: unknown
}) => VNode[]
}>()

// Use the useTexture composable to load the texture
const { state: texture, isLoading, error } = useTexture(props.path)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { computed, onBeforeUnmount, shallowRef, toValue, watch } from 'vue'
import type { TresColor } from '@tresjs/core'
import { BlurPass } from './BlurPass'
import { MeshReflectionMaterial } from './material'
import { WebGPURenderer } from 'three/webgpu'

export interface MeshReflectionMaterialProps {

Expand Down Expand Up @@ -282,7 +281,9 @@ const { onBeforeRender } = useLoop()
onBeforeRender(({ renderer, scene, camera }) => {
const parent = (materialRef.value as any)?.__tres?.parent
if (!parent) { return }
if (renderer instanceof WebGPURenderer) {

// compatible with v0.133.0 - v0.166.0
if (renderer.constructor.name === 'WebGPURenderer') {
console.warn('MeshReflectionMaterial: WebGPURenderer is not supported yet')
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class EnvironmentScene extends Object3D {
this.virtualScene = new Scene()
}

// @ts-expect-error - No idea how to fix the type error here
add(...object: Object3D[]): this {
for (const obj of object) {
this.virtualScene.add(obj)
Expand Down
20 changes: 17 additions & 3 deletions packages/cientos/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'trescientos',
fileName: 'trescientos',
formats: ['es'],
},
copyPublicDir: false,
Expand All @@ -61,7 +59,23 @@ export default defineConfig({
],
external: ['three', 'vue', '@tresjs/core'],
output: {
exports: 'named',
preserveModules: true,
preserveModulesRoot: 'src',
entryFileNames: (chunkInfo) => {
const name = chunkInfo.name || 'index'

// Put external dependencies and virtual modules in specific directories
if (name.includes('node_modules')) {
return `external/${name.replace(/.*node_modules\//, '')}.js`
}

if (name.includes('_virtual')) {
return `virtual/${name.replace('_virtual/', '')}.js`
}

// Use cleaned path for source code files
return `${name}.js`
},
},
},
},
Expand Down