Skip to content

Commit

Permalink
chore: revert perfectionist sort
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Sep 17, 2024
1 parent 636ee52 commit 107bb39
Show file tree
Hide file tree
Showing 39 changed files with 87 additions and 88 deletions.
4 changes: 2 additions & 2 deletions docs/.vitepress/theme/components/LocalOrbitControls.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts" setup>
import type { TresVector3 } from '@tresjs/core'
import type { Camera } from 'three'
import { extend, useRenderLoop, useTresContext } from '@tresjs/core'
import { useEventListener } from '@vueuse/core'
import { OrbitControls } from 'three-stdlib'
import { onMounted, onUnmounted, shallowRef, unref } from 'vue'
import type { TresVector3 } from '@tresjs/core'
import type { Camera } from 'three'
export interface OrbitControlsProps {
/**
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/theme/components/StackBlitzEmbed.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { EmbedOptions } from '@stackblitz/sdk'
import sdk from '@stackblitz/sdk'
import { ref, watch } from 'vue'
import type { EmbedOptions } from '@stackblitz/sdk'
const props = withDefaults(
defineProps<{
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import VPTheme from 'vitepress/theme'
import type { Theme } from 'vitepress'
import VPTheme from 'vitepress/theme'

import TresLayout from './TresLayout.vue'
import './custom.css'
Expand Down
2 changes: 1 addition & 1 deletion playground/nuxt/components/EnvironmentLocal.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { LoaderProto } from '@tresjs/core'
import { useLoader, useTresContext } from '@tresjs/core'
import { CubeReflectionMapping, type CubeTexture, CubeTextureLoader, EquirectangularReflectionMapping, type Texture } from 'three'
import { RGBELoader } from 'three-stdlib'
import type { LoaderProto } from '@tresjs/core'
/* const files = ref(['/px.jpg', '/nx.jpg', '/py.jpg', '/ny.jpg', '/pz.jpg', '/nz.jpg']) */
const files = ref('venice/venice_sunset_1k.hdr')
Expand Down
2 changes: 1 addition & 1 deletion playground/vue/src/composables/useFBX.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Object3D } from 'three'
import { useLoader } from '@tresjs/core'
import { FBXLoader } from 'three-stdlib'
import type { Object3D } from 'three'

/**
* Loads an FBX file and returns a THREE.Object3D.
Expand Down
4 changes: 2 additions & 2 deletions playground/vue/src/composables/useGLTF.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type TresLoader, type TresObject3D, useLoader } from '@tresjs/core'
import { DRACOLoader, GLTFLoader } from 'three-stdlib'
import type { AnimationClip, Material, Scene } from 'three'
import type { GLTF } from 'three-stdlib'
import { type TresLoader, type TresObject3D, useLoader } from '@tresjs/core'
import { DRACOLoader, GLTFLoader } from 'three-stdlib'

export interface GLTFLoaderOptions {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { WebGLRenderer } from 'three'
import { TresCanvas } from '@tresjs/core'
import { shallowRef } from 'vue'
import type { WebGLRenderer } from 'three'
const rendererRef = shallowRef<WebGLRenderer | null>(null)
const minDpr = 1
Expand Down
4 changes: 2 additions & 2 deletions playground/vue/src/pages/advanced/fbo/useFBO.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Camera, WebGLRenderTargetOptions } from 'three'
import type { Ref } from 'vue'
/* eslint-disable no-console */
import { useLoop, useTresContext } from '@tresjs/core'
import { useThrottleFn } from '@vueuse/core'
import { DepthTexture, FloatType, HalfFloatType, LinearFilter, WebGLRenderTarget } from 'three'
import { isReactive, onBeforeUnmount, reactive, ref, toRefs, watchEffect } from 'vue'
import type { Camera, WebGLRenderTargetOptions } from 'three'
import type { Ref } from 'vue'

export interface FboOptions {
/*
Expand Down
4 changes: 2 additions & 2 deletions playground/vue/src/pages/basic/Lights.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script setup lang="ts">
import type { TresObject } from '@tresjs/core'
import { OrbitControls } from '@tresjs/cientos'
import { TresCanvas, vDistanceTo, vLightHelper, vLog } from '@tresjs/core'
import { BasicShadowMap, NoToneMapping, SRGBColorSpace } from 'three'
import type { TresObject } from '@tresjs/core'
import { BasicShadowMap, NoToneMapping, SRGBColorSpace } from 'three'
const gl = {
clearColor: '#82DBC5',
Expand Down
4 changes: 2 additions & 2 deletions playground/vue/src/pages/basic/ready/index.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { ref } from 'vue'
import type { TresContext } from '@tresjs/core'
import type { ShallowRef } from 'vue'
import { TresCanvas } from '@tresjs/core'
import { ref } from 'vue'
import LoopCallbackWatcher from './LoopCallbackWatcher.vue'
import OnTresReadyWatcher from './OnTresReadyWatcher.vue'
Expand Down
2 changes: 1 addition & 1 deletion playground/vue/src/pages/cameras/multipleCameras/index.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type { Camera } from 'three'
import { OrbitControls } from '@tresjs/cientos'
import { TresCanvas } from '@tresjs/core'
import { TresLeches, useControls } from '@tresjs/leches'
import type { Camera } from 'three'
import TheCameraOperator from './TheCameraOperator.vue'
import '@tresjs/leches/styles'
Expand Down
2 changes: 1 addition & 1 deletion playground/vue/src/pages/events/index.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!-- eslint-disable no-console -->
<script setup lang="ts">
import type { ThreeEvent } from '@tresjs/core'
import { OrbitControls, StatsGl } from '@tresjs/cientos'
import { TresCanvas } from '@tresjs/core'
import { TresLeches, useControls } from '@tresjs/leches'
import { BasicShadowMap, NoToneMapping, SRGBColorSpace } from 'three'
import type { ThreeEvent } from '@tresjs/core'
import '@tresjs/leches/styles'

const gl = {
Expand Down
2 changes: 1 addition & 1 deletion playground/vue/src/pages/issues/701/TheExperience.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- eslint-disable no-console -->
<script setup lang="ts">
import type { BufferGeometry, Camera, Material } from 'three'
import { useLoop } from '@tresjs/core'
import {
BoxGeometry,
Expand All @@ -12,7 +13,6 @@ import {
TorusGeometry,
} from 'three'
import { onUnmounted, shallowRef } from 'vue'
import type { BufferGeometry, Camera, Material } from 'three'

const box = (() => {
const box = new Mesh(
Expand Down
22 changes: 11 additions & 11 deletions src/components/TresCanvas.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<script setup lang="ts">
import type {
ColorSpace,
ShadowMapType,
ToneMapping,
WebGLRendererParameters,
} from 'three'
import type { App, Ref } from 'vue'
import type { RendererPresetsType } from '../composables/useRenderer/const'
import type { TresCamera, TresObject, TresScene } from '../types/'
import { PerspectiveCamera, Scene } from 'three'
import * as THREE from 'three'
import {
computed,
createRenderer,
Expand All @@ -16,28 +26,18 @@ import {
watch,
watchEffect,
} from 'vue'
import type {
ColorSpace,
ShadowMapType,
ToneMapping,
WebGLRendererParameters,
} from 'three'
import type { App, Ref } from 'vue'
import pkg from '../../package.json'
import {
type TresContext,
useLogger,
useTresContextProvider,
} from '../composables'
import { extend } from '../core/catalogue'
import { nodeOps } from '../core/nodeOps'
import { registerTresDevtools } from '../devtools'
import { disposeObject3D } from '../utils/'
import type { RendererPresetsType } from '../composables/useRenderer/const'
import type { TresCamera, TresObject, TresScene } from '../types/'
export interface TresCanvasProps
extends Omit<WebGLRendererParameters, 'canvas'> {
// required by for useRenderer
Expand Down
8 changes: 4 additions & 4 deletions src/composables/useCamera/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Camera, PerspectiveCamera } from 'three'
import { computed, onUnmounted, ref, watchEffect } from 'vue'
import type { OrthographicCamera } from 'three'

import { camera as isCamera } from '../../utils/is'
import type { TresScene } from '../../types'
import type { TresContext } from '../useTresContextProvider'

import { Camera, PerspectiveCamera } from 'three'
import { computed, onUnmounted, ref, watchEffect } from 'vue'
import { camera as isCamera } from '../../utils/is'

export const useCamera = ({ sizes }: Pick<TresContext, 'sizes'> & { scene: TresScene }) => {
// the computed does not trigger, when for example the camera position changes
const cameras = ref<Camera[]>([])
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useLoader/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Loader, LoadingManager, Object3D } from 'three'
import { useLogger } from '..'
import type { TresObject } from '../../types'
import { useLogger } from '..'

export interface TresLoader<T> extends Loader {
load: (
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useLoop/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useTresContext } from '../useTresContextProvider'
import type { LoopCallbackFn } from './../../core/loop'
import { useTresContext } from '../useTresContextProvider'

export function useLoop() {
const {
Expand Down
8 changes: 4 additions & 4 deletions src/composables/useRaycaster/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createEventHook, useElementBounding, usePointer } from '@vueuse/core'
import { Vector2, Vector3 } from 'three'
import { computed, onUnmounted, shallowRef } from 'vue'
import type { EventHook } from '@vueuse/core'
import type { DomEvent, TresCamera, TresEvent, TresInstance } from 'src/types'
import type { Intersection, Object3D, Object3DEventMap } from 'three'

import type { ShallowRef } from 'vue'
import type { TresContext } from '../useTresContextProvider'
import { createEventHook, useElementBounding, usePointer } from '@vueuse/core'

import { Vector2, Vector3 } from 'three'
import { computed, onUnmounted, shallowRef } from 'vue'

export const useRaycaster = (
objectsWithEvents: ShallowRef<TresInstance[]>,
Expand Down
4 changes: 2 additions & 2 deletions src/composables/useRenderLoop/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createEventHook, useRafFn } from '@vueuse/core'
import { Clock } from 'three'
import type { EventHookOn, Fn } from '@vueuse/core'
import type { Ref } from 'vue'
import { createEventHook, useRafFn } from '@vueuse/core'
import { Clock } from 'three'

export interface RenderLoop {
delta: number
Expand Down
14 changes: 7 additions & 7 deletions src/composables/useRenderer/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import type { ColorSpace, Scene, ShadowMapType, ToneMapping, WebGLRendererParameters } from 'three'
import type { EmitEventFn, TresColor } from '../../types'

import type { TresContext } from '../useTresContextProvider'

import type { RendererPresetsType } from './const'
import {
type MaybeRefOrGetter,
toValue,
unrefElement,
useDevicePixelRatio,
} from '@vueuse/core'
import { ACESFilmicToneMapping, Color, WebGLRenderer } from 'three'

import { computed, type MaybeRef, onUnmounted, shallowRef, watch, watchEffect } from 'vue'

import type { ColorSpace, Scene, ShadowMapType, ToneMapping, WebGLRendererParameters } from 'three'
// Solution taken from Thretle that actually support different versions https://github.com/threlte/threlte/blob/5fa541179460f0dadc7dc17ae5e6854d1689379e/packages/core/src/lib/lib/useRenderer.ts
import { revision } from '../../core/revision'
import { get, merge, set, setPixelRatio } from '../../utils'
import { normalizeColor } from '../../utils/normalize'

import { normalizeColor } from '../../utils/normalize'
import { useLogger } from '../useLogger'
import { rendererPresets } from './const'

import type { EmitEventFn, TresColor } from '../../types'
import type { TresContext } from '../useTresContextProvider'
import type { RendererPresetsType } from './const'

type TransformToMaybeRefOrGetter<T> = {
[K in keyof T]: MaybeRefOrGetter<T[K]> | MaybeRefOrGetter<T[K]>;
}
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useSizes/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref } from 'vue'
import { refDebounced, toValue, useElementSize, useWindowSize } from '@vueuse/core'
import { computed, readonly } from 'vue'
import type { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref } from 'vue'

export interface SizesType {
height: Readonly<Ref<number>>
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useTexture/component.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { PBRUseTextureMap } from './index'
import { reactive } from 'vue'
import { useTexture } from './index'
import type { PBRUseTextureMap } from './index'
const props = defineProps<PBRUseTextureMap>()
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useTexture/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TextureLoader } from 'three'
import type { LoadingManager, Texture } from 'three'
import { TextureLoader } from 'three'
import { isArray } from '../../utils'

export interface PBRMaterialOptions {
Expand Down
12 changes: 6 additions & 6 deletions src/composables/useTresContextProvider/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import type { Camera, WebGLRenderer } from 'three'
import type { ComputedRef, DeepReadonly, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue'
import type { RendererLoop } from '../../core/loop'
import type { EmitEventFn, TresControl, TresObject, TresScene } from '../../types'
import type { UseRendererOptions } from '../useRenderer'
import { useFps, useMemory, useRafFn } from '@vueuse/core'
import { Raycaster } from 'three'
import { computed, inject, onUnmounted, provide, readonly, ref, shallowRef } from 'vue'
import type { Camera, WebGLRenderer } from 'three'
import type { ComputedRef, DeepReadonly, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue'
import { extend } from '../../core/catalogue'
import { createRenderLoop } from '../../core/loop'
import { calculateMemoryUsage } from '../../utils/perf'

import { useCamera } from '../useCamera'
import { useRenderer } from '../useRenderer'
import useSizes, { type SizesType } from '../useSizes'

import { type TresEventManager, useTresEventManager } from '../useTresEventManager'
import { useTresReady } from '../useTresReady'
import type { RendererLoop } from '../../core/loop'
import type { EmitEventFn, TresControl, TresObject, TresScene } from '../../types'
import type { UseRendererOptions } from '../useRenderer'

export interface InternalState {
priority: Ref<number>
Expand Down
4 changes: 2 additions & 2 deletions src/composables/useTresEventManager/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { shallowRef } from 'vue'
import type { EmitEventFn, EmitEventName, Intersection, TresEvent, TresInstance, TresObject } from 'src/types'
import type { Object3D, Object3DEventMap, Scene } from 'three'
import type { TresContext } from '../useTresContextProvider'
import { shallowRef } from 'vue'
import { hyphenate } from '../../utils'
import * as is from '../../utils/is'
import { useRaycaster } from '../useRaycaster'
import type { TresContext } from '../useTresContextProvider'

export interface TresEventManager {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useTresReady/createReadyEventHook/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createEventHook } from '@vueuse/core'
import type { EventHook, EventHookOn, IsAny } from '@vueuse/core'
import { createEventHook } from '@vueuse/core'

type Callback<T> =
IsAny<T> extends true
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useTresReady/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TresContext } from '../useTresContextProvider'
import { useTresContext } from '../useTresContextProvider'
import { createReadyEventHook } from './createReadyEventHook'
import type { TresContext } from '../useTresContextProvider'

const ctxToUseTresReady = new WeakMap<
TresContext,
Expand Down
2 changes: 1 addition & 1 deletion src/core/catalogue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ref } from 'vue'
import type { Ref } from 'vue'
import type { TresCatalogue } from '../types'
import { ref } from 'vue'

export const catalogue: Ref<TresCatalogue> = ref({})

Expand Down
2 changes: 1 addition & 1 deletion src/core/loop.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TresContext } from '../composables/useTresContextProvider'
import { afterEach, beforeEach, it } from 'vitest'
import { createRenderLoop } from './loop'
import type { TresContext } from '../composables/useTresContextProvider'

let renderLoop

Expand Down
6 changes: 3 additions & 3 deletions src/core/loop.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Clock, MathUtils } from 'three'
import { ref, unref } from 'vue'
import type { Fn } from '@vueuse/core'
import type { Camera, EventDispatcher, Raycaster, Scene, WebGLRenderer } from 'three'
import type { Ref } from 'vue'
import { createPriorityEventHook } from '../utils/createPriorityEventHook'
import type { Callback } from '../utils/createPriorityEventHook'
import { Clock, MathUtils } from 'three'
import { ref, unref } from 'vue'
import { createPriorityEventHook } from '../utils/createPriorityEventHook'

export type LoopStage = 'before' | 'render' | 'after'

Expand Down
Loading

0 comments on commit 107bb39

Please sign in to comment.