mirror of
https://gitee.com/ice-gl/icegl-three-vue-tres.git
synced 2025-04-05 06:22:43 +08:00
no message
This commit is contained in:
parent
8bf87d7d1b
commit
bac27fe040
@ -4,7 +4,7 @@
|
||||
* @Autor: 地虎降天龙
|
||||
* @Date: 2024-04-02 18:51:33
|
||||
* @LastEditors: 地虎降天龙
|
||||
* @LastEditTime: 2024-04-08 11:38:34
|
||||
* @LastEditTime: 2024-04-08 12:16:35
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { defineProps, watchEffect, ref } from 'vue'
|
||||
@ -19,7 +19,7 @@ const colorRef = ref<any>()
|
||||
watchEffect(() => {
|
||||
if (colorRef.value) {
|
||||
if (props.color) {
|
||||
colorRef.value.color.setStyle(props.color).convertLinearToSRGB() // 注意 material.color.set('#444') 如果值不同 请 convertLinearToSRGB()
|
||||
colorRef.value.color.setStyle(props.color)//.convertLinearToSRGB() // 注意 material.color.set('#444') 如果值不同 请 convertLinearToSRGB()
|
||||
}
|
||||
if (props.alpha) {
|
||||
colorRef.value.alpha = props.alpha
|
||||
|
@ -20,10 +20,10 @@ const instanceRef = ref<any>()
|
||||
watchEffect(() => {
|
||||
if (instanceRef.value) {
|
||||
if (props.colorA) {
|
||||
instanceRef.value.colorA.set(props.colorA).convertLinearToSRGB()
|
||||
instanceRef.value.colorA.set(props.colorA)//.convertLinearToSRGB()
|
||||
}
|
||||
if (props.colorB) {
|
||||
instanceRef.value.colorB.set(props.colorB).convertLinearToSRGB()
|
||||
instanceRef.value.colorB.set(props.colorB)//.convertLinearToSRGB()
|
||||
}
|
||||
if (props.alpha) {
|
||||
instanceRef.value.alpha = props.alpha
|
||||
|
@ -16,6 +16,7 @@ const props = withDefaults(defineProps<EnvironmentOptions>(), {
|
||||
files: [],
|
||||
path: '',
|
||||
preset: undefined,
|
||||
resolution: 256
|
||||
})
|
||||
|
||||
const texture: Ref<Texture | CubeTexture | null> = ref(null)
|
||||
@ -29,7 +30,7 @@ if (useSlots().default !== undefined) {
|
||||
extend({ EnvSence })
|
||||
//@ts-ignore
|
||||
slots = useSlots().default()
|
||||
fbo = new THREE.WebGLCubeRenderTarget(256)
|
||||
fbo = new THREE.WebGLCubeRenderTarget(props.resolution)
|
||||
fbo.texture.type = THREE.HalfFloatType
|
||||
cubeCamera = new THREE.CubeCamera(1, 10000, fbo)
|
||||
}
|
||||
@ -45,9 +46,9 @@ onBeforeLoop(() => {
|
||||
}
|
||||
})
|
||||
//@ts-ignore
|
||||
const useEnvironmentTexture = useEnvironment(props).texture
|
||||
const useEnvironmentTexture = await useEnvironment(props).texture
|
||||
watch(useEnvironmentTexture, (value) => {
|
||||
if (value && fbo) {
|
||||
if (fbo) {
|
||||
scene.value.environment = fbo.texture
|
||||
if (props.background) {
|
||||
scene.value.background = fbo.texture
|
||||
|
@ -1,3 +1,11 @@
|
||||
/*
|
||||
* @Description:
|
||||
* @Version: 1.668
|
||||
* @Autor: 地虎降天龙
|
||||
* @Date: 2024-04-07 11:36:45
|
||||
* @LastEditors: 地虎降天龙
|
||||
* @LastEditTime: 2024-04-08 11:56:25
|
||||
*/
|
||||
|
||||
export interface EnvironmentOptions {
|
||||
/**
|
||||
@ -34,6 +42,13 @@ export interface EnvironmentOptions {
|
||||
* @type {EnvironmentPresetsType}
|
||||
*/
|
||||
preset?: EnvironmentPresetsType
|
||||
/**
|
||||
* The resolution of the WebGLCubeRenderTarget.
|
||||
*
|
||||
* @type {number}
|
||||
* @default 0
|
||||
*/
|
||||
resolution?: number
|
||||
}
|
||||
|
||||
export const environmentPresets = {
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @Autor: 地虎降天龙
|
||||
* @Date: 2024-04-07 18:13:49
|
||||
* @LastEditors: 地虎降天龙
|
||||
* @LastEditTime: 2024-04-08 11:41:43
|
||||
* @LastEditTime: 2024-04-08 12:00:23
|
||||
*/
|
||||
|
||||
import * as THREE from 'three'
|
||||
@ -14,7 +14,7 @@ class EnvSence extends THREE.Object3D {
|
||||
virtualScene = null as unknown as THREE.Scene
|
||||
// parent = null as unknown as THREE.Object3D
|
||||
constructor() {
|
||||
console.log('EnvSence constructor')
|
||||
// console.log('EnvSence constructor')
|
||||
super()
|
||||
this.virtualScene = new THREE.Scene()
|
||||
}
|
||||
@ -32,7 +32,7 @@ class EnvSence extends THREE.Object3D {
|
||||
}
|
||||
})
|
||||
this.virtualScene = null as unknown as THREE.Scene
|
||||
console.log('EnvSence destructor')
|
||||
// console.log('EnvSence destructor')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,13 +4,13 @@
|
||||
* @Autor: 地虎降天龙
|
||||
* @Date: 2024-04-07 14:29:57
|
||||
* @LastEditors: 地虎降天龙
|
||||
* @LastEditTime: 2024-04-08 11:52:44
|
||||
* @LastEditTime: 2024-04-08 12:16:04
|
||||
-->
|
||||
<template>
|
||||
<TresCanvas v-bind="tcConfig">
|
||||
<TresPerspectiveCamera :position="[15, 15, 15]" :fov="45" :near="0.1" :far="10000" :look-at="[0, 0, 0]" />
|
||||
<OrbitControls enableDamping />
|
||||
<TresAmbientLight :intensity="10.0" />
|
||||
<TresAmbientLight :intensity="0.5" />
|
||||
|
||||
<TresMesh :position="[3, 2, 1]" cast-shadow>
|
||||
<TresBoxGeometry :args="[3, 3, 3]" />
|
||||
@ -23,8 +23,7 @@
|
||||
</TresMesh>
|
||||
|
||||
<Suspense>
|
||||
<Environment files="https://opensource-1314935952.cos.ap-nanjing.myqcloud.com/images/skyBox/desert_1k.hdr"
|
||||
background>
|
||||
<Environment :blur="1" background>
|
||||
<TresMesh :scale="[100, 100, 100]">
|
||||
<TresSphereGeometry :args="[1, 64, 64]" />
|
||||
<LayerMaterial :side="THREE.BackSide">
|
||||
|
Loading…
x
Reference in New Issue
Block a user