Skip to content

Commit 2cbcb8a

Browse files
committed
build: the v0.3.0 release
1 parent 0a57b36 commit 2cbcb8a

File tree

22 files changed

+835
-66
lines changed

22 files changed

+835
-66
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"Realsee",
101101
"redrun",
102102
"restapi",
103+
"rgba",
103104
"safelist",
104105
"Segi",
105106
"semibold",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nicepkg/vr360",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"private": true,
55
"packageManager": "pnpm@7.0.0",
66
"author": "yangjinming",

packages/doc/.vuepress/client.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ export default defineClientConfig({
1010
if (!__VUEPRESS_SSR__) {
1111
window.loadCodeDemoModeDefaultFiles = async _mode => {
1212
const mode = _mode as 'node' | 'vue2' | 'vue3' | 'react' | 'html'
13+
14+
const defaultFiles: ProjectFiles = {
15+
'src/vr360-config.ts': (await import('./public/code-demo-templates/vr360-config.ts.txt?raw')).default
16+
}
17+
1318
switch (mode) {
1419
case 'node':
1520
case 'vue3':
1621
return {
22+
...defaultFiles,
1723
'src/App.vue': (await import('./public/code-demo-templates/vue3/src/App.vue.txt?raw')).default,
1824
'src/main.ts': (await import('./public/code-demo-templates/vue3/src/main.ts.txt?raw')).default,
1925
'types/module.d.ts': (await import('./public/code-demo-templates/vue3/types/module.d.ts.txt?raw'))
@@ -29,6 +35,7 @@ export default defineClientConfig({
2935
} as ProjectFiles
3036
case 'vue2':
3137
return {
38+
...defaultFiles,
3239
'src/App.vue': (await import('./public/code-demo-templates/vue2/src/App.vue.txt?raw')).default,
3340
'src/main.ts': (await import('./public/code-demo-templates/vue2/src/main.ts.txt?raw')).default,
3441
'types/module.d.ts': (await import('./public/code-demo-templates/vue2/types/module.d.ts.txt?raw'))
@@ -44,6 +51,7 @@ export default defineClientConfig({
4451
} as ProjectFiles
4552
case 'react':
4653
return {
54+
...defaultFiles,
4755
'src/main.tsx': (await import('./public/code-demo-templates/react/src/main.tsx.txt?raw')).default,
4856
'index.html': (await import('./public/code-demo-templates/react/index.html.txt?raw')).default,
4957
'package.json': (await import('./public/code-demo-templates/react/package.json.txt?raw')).default,
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
<template>
2+
<div class="demoA">
3+
<div
4+
ref="tipRef"
5+
class="demoA-tip"
6+
:style="{
7+
transform: `translate(${tipLeft}px, ${tipTop + 50}px)`,
8+
zIndex: showTip ? 99 : -1
9+
}"
10+
>
11+
<div class="demoA-tip-title">{{ tipTitle }}</div>
12+
<div class="demoA-tip-content">{{ tipContent }}</div>
13+
</div>
14+
<div ref="containerRef" class="demoA-container"></div>
15+
<div class="demoA-bottom-bar">
16+
<div
17+
v-for="space in spacesConfig"
18+
:key="space.id"
19+
class="demoA-bottom-card"
20+
:style="{
21+
backgroundImage: `url(${space.cubeSpaceTextureUrls.left})`
22+
}"
23+
@click="handleSwitchSpace(space)"
24+
></div>
25+
</div>
26+
</div>
27+
</template>
28+
29+
<script setup lang="ts">
30+
/* eslint-disable import/no-named-as-default-member */
31+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
32+
import {onMounted, ref} from 'vue'
33+
import type {SpaceConfig} from '@nicepkg/vr360-core'
34+
import {Vr360} from '@nicepkg/vr360-core'
35+
import textures from '../../../../textures.json'
36+
37+
const containerRef = ref<HTMLElement>()
38+
39+
const tipRef = ref<HTMLElement>()
40+
const tipLeft = ref(0)
41+
const tipTop = ref(0)
42+
const showTip = ref(false)
43+
const tipTitle = ref('')
44+
const tipContent = ref('')
45+
46+
let vr360: InstanceType<typeof Vr360>
47+
48+
const spacesConfig = ref<SpaceConfig[]>([
49+
{
50+
id: 'roomA',
51+
camera: {
52+
position: {
53+
x: 0,
54+
y: 0,
55+
z: 0
56+
}
57+
},
58+
tips: [
59+
{
60+
id: '1',
61+
position: {x: 0, y: -10, z: 40},
62+
content: {
63+
title: '豪华跑车',
64+
text: '比奥迪还贵的豪华跑车'
65+
}
66+
},
67+
{
68+
id: '2',
69+
textureUrl: textures.hotpot,
70+
targetSpaceId: 'roomB',
71+
position: {x: -10, y: -4, z: 40},
72+
content: {
73+
title: '去客厅',
74+
text: '一起去尊贵的客厅吧'
75+
}
76+
}
77+
],
78+
cubeSpaceTextureUrls: textures.firstHouseDoor
79+
},
80+
{
81+
id: 'roomB',
82+
camera: {
83+
position: {
84+
x: 0,
85+
y: 0,
86+
z: 0
87+
}
88+
},
89+
tips: [
90+
{
91+
id: '3',
92+
position: {x: -2, y: -25, z: 40},
93+
content: {
94+
title: '香奈儿垃圾桶',
95+
text: '里面装着主人不用的奢侈品'
96+
}
97+
},
98+
{
99+
id: '4',
100+
position: {x: -20, y: 0, z: 40},
101+
content: {
102+
title: '宇宙牌冰箱',
103+
text: '装着超级多零食'
104+
}
105+
},
106+
{
107+
id: '5',
108+
textureUrl: textures.hotpot,
109+
targetSpaceId: 'roomA',
110+
position: {
111+
x: -8,
112+
y: 0,
113+
z: -40
114+
},
115+
content: {
116+
title: '去门口',
117+
text: '一起去门口吧'
118+
}
119+
}
120+
],
121+
cubeSpaceTextureUrls: textures.firstHouseLivingRoom
122+
}
123+
])
124+
125+
function handleSwitchSpace(space: SpaceConfig) {
126+
vr360.switchSpace(space.id)
127+
}
128+
129+
onMounted(() => {
130+
vr360 = new Vr360({
131+
container: containerRef.value!,
132+
tipContainer: tipRef.value!,
133+
spacesConfig: spacesConfig.value
134+
})
135+
136+
vr360.controls.autoRotate = true
137+
138+
vr360.render()
139+
140+
vr360.listenResize()
141+
142+
vr360.on('showTip', e => {
143+
vr360!.controls.autoRotate = false
144+
const {top, left, tip} = e
145+
showTip.value = true
146+
tipLeft.value = left
147+
tipTop.value = top
148+
tipTitle.value = tip.content.title
149+
tipContent.value = tip.content.text
150+
})
151+
152+
vr360.on('hideTip', () => {
153+
vr360!.controls.autoRotate = true
154+
showTip.value = false
155+
})
156+
})
157+
</script>
158+
<style>
159+
.demoA {
160+
position: relative;
161+
display: flex;
162+
flex-direction: column;
163+
width: 100%;
164+
height: 500px;
165+
margin-bottom: 4rem;
166+
overflow: hidden;
167+
background-color: var(--c-bg);
168+
border: 1px solid var(--c-border);
169+
border-radius: 8px;
170+
}
171+
172+
.demoA-tip {
173+
position: absolute;
174+
top: 0;
175+
left: 0;
176+
z-index: 99;
177+
display: flex;
178+
flex-direction: column;
179+
justify-content: center;
180+
width: 240px;
181+
height: 60px;
182+
padding: 4px;
183+
color: #fff;
184+
cursor: pointer;
185+
background-color: rgba(0, 0, 0, 0.5);
186+
border-radius: 4px;
187+
}
188+
189+
.demoA-tip-title {
190+
font-weight: bold;
191+
}
192+
193+
.demoA-container {
194+
width: 100%;
195+
height: 100%;
196+
}
197+
198+
.demoA-bottom-bar {
199+
display: flex;
200+
align-items: center;
201+
width: 100%;
202+
height: 100px;
203+
}
204+
205+
.demoA-bottom-card {
206+
width: 140px;
207+
height: 70px;
208+
margin-left: 1rem;
209+
cursor: pointer;
210+
background-repeat: no-repeat;
211+
background-size: cover;
212+
border-radius: 4px;
213+
}
214+
</style>

packages/doc/.vuepress/plugins/code-demo/plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ export type MarkdownItRenderFn = (
2222

2323
export type CodeDemoOptions = {
2424
codeDemoMark?: string
25+
clickToLoad?: boolean
2526
}
2627

2728
export type RenderPlaceFunction = (description: string, codeBlockTokens?: Token[]) => string
2829

2930
export const codeDemoPlugin = (options: CodeDemoOptions = {}): Plugin => {
30-
const {codeDemoMark = 'demo'} = options
31+
const {codeDemoMark = 'demo', clickToLoad = false} = options
3132

3233
// const START_TYPE = `container_${codeDemoMark}_open`
3334
const END_TYPE = `container_${codeDemoMark}_close`
@@ -59,6 +60,7 @@ export const codeDemoPlugin = (options: CodeDemoOptions = {}): Plugin => {
5960
const options: CodeDemoProps = {
6061
mode,
6162
openFile,
63+
clickToLoad,
6264
project: {
6365
template: 'node',
6466
title: title || DEFAULT_EDITOR_TITLE,

packages/doc/.vuepress/plugins/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const vuepressPlugins: PluginConfig = [
1717
registerComponentsPlugin({
1818
componentsDir: pathResolve('../components')
1919
}),
20-
codeDemoPlugin()
20+
codeDemoPlugin({
21+
clickToLoad: true
22+
})
2123
]
2224

2325
if (isProd) {

packages/doc/.vuepress/public/code-demo-templates/react/package.json.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
"serve": "vite preview"
88
},
99
"dependencies": {
10+
"@nicepkg/vr360-core": "latest",
1011
"clsx": "^1.2.1",
1112
"react": "17.0.2",
12-
"react-dom": "17.0.2"
13+
"react-dom": "17.0.2",
14+
"three": "^0.145.0"
1315
},
1416
"devDependencies": {
1517
"@types/node": "^18.7.23",
1618
"@types/react": "18.0.21",
1719
"@types/react-dom": "18.0.6",
20+
"@types/three": "^0.144.0",
1821
"@unocss/reset": "^0.45.26",
1922
"@vitejs/plugin-react": "^2.1.0",
2023
"typescript": "4.7.4",

0 commit comments

Comments
 (0)