Skip to content

Commit

Permalink
feat(Lensflare): clean up imports
Browse files Browse the repository at this point in the history
  • Loading branch information
andretchen0 committed Sep 2, 2023
1 parent 9279cfe commit b8ef198
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
8 changes: 4 additions & 4 deletions playground/src/pages/LensflareDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { shallowRef } from 'vue'
import { TresCanvas, useRenderLoop } from '@tresjs/core'
import { RandUtils, Levioso, Lensflare, Dodecahedron } from '@tresjs/cientos';
import * as THREE from 'three';
import { Color, MeshPhongMaterial } from 'three';
import { OrbitControls } from '@tresjs/cientos'
Expand Down Expand Up @@ -30,7 +30,7 @@ onLoop(() => {
if (!lightRef.value) return
if (Math.random() > 0.99) {
lightRef.value.color = new THREE.Color(randomColor());
lightRef.value.color = new Color(randomColor());
flarePropsRef.value = getFlareProps()
}
});
Expand Down Expand Up @@ -58,7 +58,7 @@ const rocks = new Array(ROCK_COUNT).fill(0).map((_, i) => ({
key: i
}));
const rockMaterial = new THREE.MeshPhongMaterial({ color: 0x123141, specular: 0xffffff, shininess: 1000 });
const rockMaterial = new MeshPhongMaterial({ color: 0x123141, specular: 0xffffff, shininess: 1000 });
</script>

Expand All @@ -73,7 +73,7 @@ const rockMaterial = new THREE.MeshPhongMaterial({ color: 0x123141, specular: 0x
<Lensflare :seed="10" :flare="flarePropsRef" />
</TresPointLight>
</Levioso>
<TresPointLight :color="new THREE.Color(1, 1, 1)" :intensity="2000" :position="[10, 5, 0]">
<TresPointLight :color="new Color(1, 1, 1)" :intensity="2000" :position="[10, 5, 0]">
<Lensflare :seed="Math.random()" />
</TresPointLight>
<Dodecahedron v-for="{ key, position, rotation, scale } in rocks" :key="key" :material="rockMaterial"
Expand Down
15 changes: 7 additions & 8 deletions src/core/abstractions/Lensflare.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<script setup lang="ts">
import { Lensflare, LensflareElement } from 'three/addons/objects/Lensflare.js';
import * as THREE from 'three';
import { watch, shallowRef, onMounted } from 'vue'
import { Lensflare, LensflareElement } from 'three/examples/jsm/objects/lensflare';
import { MathUtils, Texture, TextureLoader, Color } from 'three';
import { watch, shallowRef, onMounted, onUnmounted } from 'vue'
import { normalizeColor } from '@tresjs/core';
import RandUtils from '../../utils/RandUtils';
import { onUnmounted } from 'vue';
export type FlareElementProps = {
texture?: THREE.Texture | string
texture?: Texture | string
size?: number
distance?: number
}
Expand All @@ -31,7 +30,7 @@ defineExpose({
value: lensflareRef,
});
const textureLoader = new THREE.TextureLoader();
const textureLoader = new TextureLoader();
function linear(x: number): number {
return x;
Expand Down Expand Up @@ -66,7 +65,7 @@ function easeOutBounce(x: number): number {
const easingFunctions = [linear, easeInCubic, easeInOutCubic, easeInQuart, easeOutBounce];
const lerp = THREE.MathUtils.lerp;
const lerp = MathUtils.lerp;
const TEXTURE_PATH = 'https://raw.githubusercontent.com/andretchen0/tresjs_assets/' +
'b1bc3780de73a9328a530767c9a7f4cbab060396/textures/lensflare/';
Expand Down Expand Up @@ -204,7 +203,7 @@ const defaultElement: LensflareElement = {
texture: `${TEXTURE_PATH}cirlceBlur.png`,
size: 64,
distance: 0,
color: new THREE.Color("white")
color: new Color("white")
}
const threeLensflare = new Lensflare();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/RandUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MathUtils } from 'THREE'
import { MathUtils } from 'three'
const clamp = MathUtils.clamp

/**
Expand Down

0 comments on commit b8ef198

Please sign in to comment.