Skip to content

Commit

Permalink
build: the v0.3.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
2214962083 committed Oct 2, 2022
1 parent 0a57b36 commit 2cbcb8a
Show file tree
Hide file tree
Showing 22 changed files with 835 additions and 66 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"Realsee",
"redrun",
"restapi",
"rgba",
"safelist",
"Segi",
"semibold",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nicepkg/vr360",
"version": "0.2.1",
"version": "0.3.0",
"private": true,
"packageManager": "pnpm@7.0.0",
"author": "yangjinming",
Expand Down
8 changes: 8 additions & 0 deletions packages/doc/.vuepress/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ export default defineClientConfig({
if (!__VUEPRESS_SSR__) {
window.loadCodeDemoModeDefaultFiles = async _mode => {
const mode = _mode as 'node' | 'vue2' | 'vue3' | 'react' | 'html'

const defaultFiles: ProjectFiles = {
'src/vr360-config.ts': (await import('./public/code-demo-templates/vr360-config.ts.txt?raw')).default
}

switch (mode) {
case 'node':
case 'vue3':
return {
...defaultFiles,
'src/App.vue': (await import('./public/code-demo-templates/vue3/src/App.vue.txt?raw')).default,
'src/main.ts': (await import('./public/code-demo-templates/vue3/src/main.ts.txt?raw')).default,
'types/module.d.ts': (await import('./public/code-demo-templates/vue3/types/module.d.ts.txt?raw'))
Expand All @@ -29,6 +35,7 @@ export default defineClientConfig({
} as ProjectFiles
case 'vue2':
return {
...defaultFiles,
'src/App.vue': (await import('./public/code-demo-templates/vue2/src/App.vue.txt?raw')).default,
'src/main.ts': (await import('./public/code-demo-templates/vue2/src/main.ts.txt?raw')).default,
'types/module.d.ts': (await import('./public/code-demo-templates/vue2/types/module.d.ts.txt?raw'))
Expand All @@ -44,6 +51,7 @@ export default defineClientConfig({
} as ProjectFiles
case 'react':
return {
...defaultFiles,
'src/main.tsx': (await import('./public/code-demo-templates/react/src/main.tsx.txt?raw')).default,
'index.html': (await import('./public/code-demo-templates/react/index.html.txt?raw')).default,
'package.json': (await import('./public/code-demo-templates/react/package.json.txt?raw')).default,
Expand Down
214 changes: 214 additions & 0 deletions packages/doc/.vuepress/components/DemoA.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
<template>
<div class="demoA">
<div
ref="tipRef"
class="demoA-tip"
:style="{
transform: `translate(${tipLeft}px, ${tipTop + 50}px)`,
zIndex: showTip ? 99 : -1
}"
>
<div class="demoA-tip-title">{{ tipTitle }}</div>
<div class="demoA-tip-content">{{ tipContent }}</div>
</div>
<div ref="containerRef" class="demoA-container"></div>
<div class="demoA-bottom-bar">
<div
v-for="space in spacesConfig"
:key="space.id"
class="demoA-bottom-card"
:style="{
backgroundImage: `url(${space.cubeSpaceTextureUrls.left})`
}"
@click="handleSwitchSpace(space)"
></div>
</div>
</div>
</template>

<script setup lang="ts">
/* eslint-disable import/no-named-as-default-member */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import {onMounted, ref} from 'vue'
import type {SpaceConfig} from '@nicepkg/vr360-core'
import {Vr360} from '@nicepkg/vr360-core'
import textures from '../../../../textures.json'
const containerRef = ref<HTMLElement>()
const tipRef = ref<HTMLElement>()
const tipLeft = ref(0)
const tipTop = ref(0)
const showTip = ref(false)
const tipTitle = ref('')
const tipContent = ref('')
let vr360: InstanceType<typeof Vr360>
const spacesConfig = ref<SpaceConfig[]>([
{
id: 'roomA',
camera: {
position: {
x: 0,
y: 0,
z: 0
}
},
tips: [
{
id: '1',
position: {x: 0, y: -10, z: 40},
content: {
title: '豪华跑车',
text: '比奥迪还贵的豪华跑车'
}
},
{
id: '2',
textureUrl: textures.hotpot,
targetSpaceId: 'roomB',
position: {x: -10, y: -4, z: 40},
content: {
title: '去客厅',
text: '一起去尊贵的客厅吧'
}
}
],
cubeSpaceTextureUrls: textures.firstHouseDoor
},
{
id: 'roomB',
camera: {
position: {
x: 0,
y: 0,
z: 0
}
},
tips: [
{
id: '3',
position: {x: -2, y: -25, z: 40},
content: {
title: '香奈儿垃圾桶',
text: '里面装着主人不用的奢侈品'
}
},
{
id: '4',
position: {x: -20, y: 0, z: 40},
content: {
title: '宇宙牌冰箱',
text: '装着超级多零食'
}
},
{
id: '5',
textureUrl: textures.hotpot,
targetSpaceId: 'roomA',
position: {
x: -8,
y: 0,
z: -40
},
content: {
title: '去门口',
text: '一起去门口吧'
}
}
],
cubeSpaceTextureUrls: textures.firstHouseLivingRoom
}
])
function handleSwitchSpace(space: SpaceConfig) {
vr360.switchSpace(space.id)
}
onMounted(() => {
vr360 = new Vr360({
container: containerRef.value!,
tipContainer: tipRef.value!,
spacesConfig: spacesConfig.value
})
vr360.controls.autoRotate = true
vr360.render()
vr360.listenResize()
vr360.on('showTip', e => {
vr360!.controls.autoRotate = false
const {top, left, tip} = e
showTip.value = true
tipLeft.value = left
tipTop.value = top
tipTitle.value = tip.content.title
tipContent.value = tip.content.text
})
vr360.on('hideTip', () => {
vr360!.controls.autoRotate = true
showTip.value = false
})
})
</script>
<style>
.demoA {
position: relative;
display: flex;
flex-direction: column;
width: 100%;
height: 500px;
margin-bottom: 4rem;
overflow: hidden;
background-color: var(--c-bg);
border: 1px solid var(--c-border);
border-radius: 8px;
}
.demoA-tip {
position: absolute;
top: 0;
left: 0;
z-index: 99;
display: flex;
flex-direction: column;
justify-content: center;
width: 240px;
height: 60px;
padding: 4px;
color: #fff;
cursor: pointer;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 4px;
}
.demoA-tip-title {
font-weight: bold;
}
.demoA-container {
width: 100%;
height: 100%;
}
.demoA-bottom-bar {
display: flex;
align-items: center;
width: 100%;
height: 100px;
}
.demoA-bottom-card {
width: 140px;
height: 70px;
margin-left: 1rem;
cursor: pointer;
background-repeat: no-repeat;
background-size: cover;
border-radius: 4px;
}
</style>
4 changes: 3 additions & 1 deletion packages/doc/.vuepress/plugins/code-demo/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ export type MarkdownItRenderFn = (

export type CodeDemoOptions = {
codeDemoMark?: string
clickToLoad?: boolean
}

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

export const codeDemoPlugin = (options: CodeDemoOptions = {}): Plugin => {
const {codeDemoMark = 'demo'} = options
const {codeDemoMark = 'demo', clickToLoad = false} = options

// const START_TYPE = `container_${codeDemoMark}_open`
const END_TYPE = `container_${codeDemoMark}_close`
Expand Down Expand Up @@ -59,6 +60,7 @@ export const codeDemoPlugin = (options: CodeDemoOptions = {}): Plugin => {
const options: CodeDemoProps = {
mode,
openFile,
clickToLoad,
project: {
template: 'node',
title: title || DEFAULT_EDITOR_TITLE,
Expand Down
4 changes: 3 additions & 1 deletion packages/doc/.vuepress/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const vuepressPlugins: PluginConfig = [
registerComponentsPlugin({
componentsDir: pathResolve('../components')
}),
codeDemoPlugin()
codeDemoPlugin({
clickToLoad: true
})
]

if (isProd) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
"serve": "vite preview"
},
"dependencies": {
"@nicepkg/vr360-core": "latest",
"clsx": "^1.2.1",
"react": "17.0.2",
"react-dom": "17.0.2"
"react-dom": "17.0.2",
"three": "^0.145.0"
},
"devDependencies": {
"@types/node": "^18.7.23",
"@types/react": "18.0.21",
"@types/react-dom": "18.0.6",
"@types/three": "^0.144.0",
"@unocss/reset": "^0.45.26",
"@vitejs/plugin-react": "^2.1.0",
"typescript": "4.7.4",
Expand Down
Loading

1 comment on commit 2cbcb8a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for vr-360 ready!

✅ Preview
https://vr-360-hd2qlki9x-2214962083.vercel.app

Built with commit 2cbcb8a.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.