-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Drei Vanilla"’s MeshTransmissionMaterial renders only black sphere #874
Comments
I found an older version of It reproduces an example of // useNoise.ts
import { useLoop } from '@tresjs/core';
import { shallowRef } from '@vue/reactivity';
import { ref } from 'vue';
export default function useNoise({ intensity = 0.03, speed = 0.2 } = {}) {
const mesh = shallowRef();
const originalPositions = ref();
const time = ref(0);
const { onBeforeRender } = useLoop();
onBeforeRender(({ delta }) => {
time.value += delta * speed;
if (mesh.value && mesh.value.geometry) {
const positions = mesh.value.geometry.attributes.position.array;
// Store original positions if not already stored
if (!originalPositions.value) {
originalPositions.value = new Float32Array(positions.length);
for (let i = 0; i < positions.length; i++) {
originalPositions.value[i] = positions[i];
}
}
// Update each vertex position with noise
for (let i = 0; i < positions.length; i += 3) {
const x = originalPositions.value[i];
const y = originalPositions.value[i + 1];
const z = originalPositions.value[i + 2];
// Create noise based on position and time
const noise =
(Math.sin(x * 5 + time.value) +
Math.sin(y * 5 + time.value) +
Math.sin(z * 5 + time.value)) *
intensity;
// Apply noise in the direction of the vertex normal
const length = Math.sqrt(x * x + y * y + z * z);
positions[i] = x + (x / length) * noise;
positions[i + 1] = y + (y / length) * noise;
positions[i + 2] = z + (z / length) * noise;
}
mesh.value.geometry.attributes.position.needsUpdate = true;
mesh.value.rotation.y += delta * 0.2;
mesh.value.rotation.z += delta * 0.1;
}
});
return { mesh };
} |
By the way:
|
Hey @AndreasFaust, this is quite useful.
For For
It can't be worked around with |
Thanks for the feedback. I have |
Describe the bug
This is more likely me doing something wrong than a bug. I am trying to setup a simple scene, where a sphere is put in front of a plane with a photo.
The sphere has Meshtransmissionmaterial applied to it. It seems to work but the sphere is only black instead of transparent.
The text was updated successfully, but these errors were encountered: