Skip to content
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

position type is incorrect #696

Open
4 tasks done
wangxiaoze-view opened this issue May 27, 2024 · 0 comments
Open
4 tasks done

position type is incorrect #696

wangxiaoze-view opened this issue May 27, 2024 · 0 comments

Comments

@wangxiaoze-view
Copy link

Description

I defined a camera and a light and used the :position attribute, but the type error was displayed in vscode; so I changed :position="[3, 3,3]" to:position="new THREE. Vector3(0, 3, 3)" results in no type error;

I don't know if it's a version problem or a package version problem.

Suggested solution

<script setup lang="ts">
	import * as THREE from 'three'
	import { TresCanvas } from '@tresjs/core'
	import { OrbitControls, vLightHelper } from '@tresjs/cientos'

	import Texture_02 from '@/components/texture/texture_02/index.vue'
	defineOptions({
		dir_name: 'stickers',
	})
</script>

<template>
	<div class="container">
		<TresCanvas shadows clear-color="#82DBC5" preset="realistic" alpha power-preference="high-performance">
			<OrbitControls />

                        <!-- There will be a type problem here -->
			<TresPerspectiveCamera :position="[3, 3, 3]" :look-at="[0, 0, 0]" />

			<Suspense>
				<Texture_02 />
			</Suspense>

                         <!-- OK -->
			<TresDirectionalLight :intensity="1" :position="new THREE.Vector3(0, 3, 3)" v-light-helper />
		</TresCanvas>
	</div>
</template>

<style lang="scss" scoped>
	.container {
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>

Alternative

At first I thought: position="new THREE.Vector3(0, 3, 3)" is a better way to understand the original parameters of threejs, but after reading the documentation, I found: position="[0,3,3]" is simpler ;But the recommended writing method in the document is: position="[0,3,3]"

image

Additional context

image
image

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant