[feat] 3d loader

This commit is contained in:
kwaroran
2023-07-16 01:33:52 +09:00
parent cf617495f9
commit a14e8655ae
7 changed files with 126 additions and 1 deletions

View File

@@ -44,6 +44,7 @@
"rollup": "^3.21.3",
"showdown": "^2.1.0",
"sweetalert2": "^11.7.3",
"three": "^0.154.0",
"uuid": "^9.0.0",
"wasmoon": "^1.15.0",
"web-streams-polyfill": "^3.2.1"
@@ -61,6 +62,7 @@
"@types/node": "^18.7.10",
"@types/pngjs": "^6.0.1",
"@types/showdown": "^2.0.0",
"@types/three": "^0.154.0",
"@types/uuid": "^9.0.1",
"@types/wicg-file-system-access": "^2020.9.6",
"autoprefixer": "^10.4.14",

45
pnpm-lock.yaml generated
View File

@@ -95,6 +95,9 @@ dependencies:
sweetalert2:
specifier: ^11.7.3
version: 11.7.3
three:
specifier: ^0.154.0
version: 0.154.0
uuid:
specifier: ^9.0.0
version: 9.0.0
@@ -142,6 +145,9 @@ devDependencies:
'@types/showdown':
specifier: ^2.0.0
version: 2.0.0
'@types/three':
specifier: ^0.154.0
version: 0.154.0
'@types/uuid':
specifier: ^9.0.1
version: 9.0.1
@@ -758,6 +764,10 @@ packages:
resolution: {integrity: sha512-pYrtLtOwku/7r1i9AMONsJMVYAtk3hzOfiGNekhtq5tYBGA7unMve8RvUclKLMT3PrihvJqUmzsRGh0RP84hKg==}
dev: true
/@tweenjs/tween.js@18.6.4:
resolution: {integrity: sha512-lB9lMjuqjtuJrx7/kOkqQBtllspPIN+96OvTCeJ2j5FEzinoAXTdAMFnDAQT1KVPRlnYfBrqxtqP66vDM40xxQ==}
dev: true
/@types/blueimp-md5@2.18.0:
resolution: {integrity: sha512-f4A+++lGZGJvVSgeyMkqA7BEf2BVQli6F+qEykKb49c5ieWQBkfpn6CP5c1IZr2Yi2Ofl6Fj+v0e1fN18Z8Cnw==}
dev: true
@@ -812,6 +822,21 @@ packages:
resolution: {integrity: sha512-70xBJoLv+oXjB5PhtA8vo7erjLDp9/qqI63SRHm4REKrwuPOLs8HhXwlZJBJaB4kC18cCZ1UUZ6Fb/PLFW4TCA==}
dev: true
/@types/stats.js@0.17.0:
resolution: {integrity: sha512-9w+a7bR8PeB0dCT/HBULU2fMqf6BAzvKbxFboYhmDtDkKPiyXYbjoe2auwsXlEFI7CFNMF1dCv3dFH5Poy9R1w==}
dev: true
/@types/three@0.154.0:
resolution: {integrity: sha512-IioqpGhch6FdLDh4zazRn3rXHj6Vn2nVOziJdXVbJFi9CaI65LtP9qqUtpzbsHK2Ezlox8NtsLNHSw3AQzucjA==}
dependencies:
'@tweenjs/tween.js': 18.6.4
'@types/stats.js': 0.17.0
'@types/webxr': 0.5.2
fflate: 0.6.10
lil-gui: 0.17.0
meshoptimizer: 0.18.1
dev: true
/@types/tough-cookie@4.0.2:
resolution: {integrity: sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==}
@@ -822,6 +847,10 @@ packages:
resolution: {integrity: sha512-rFT3ak0/2trgvp4yYZo5iKFEPsET7vKydKF+VRCxlQ9bpheehyAJH89dAkaLEq/j/RZXJIqcgsmPJKUP1Z28HA==}
dev: true
/@types/webxr@0.5.2:
resolution: {integrity: sha512-szL74BnIcok9m7QwYtVmQ+EdIKwbjPANudfuvDrAF8Cljg9MKUlIoc1w5tjj9PMpeSH3U1Xnx//czQybJ0EfSw==}
dev: true
/@types/wicg-file-system-access@2020.9.6:
resolution: {integrity: sha512-6hogE75Hl2Ov/jgp8ZhDaGmIF/q3J07GtXf8nCJCwKTHq7971po5+DId7grft09zG7plBwpF6ZU0yx9Du4/e1A==}
dev: true
@@ -1442,6 +1471,10 @@ packages:
reusify: 1.0.4
dev: true
/fflate@0.6.10:
resolution: {integrity: sha512-IQrh3lEPM93wVCEczc9SaAOvkmcoQn/G8Bo1e8ZPlY3X3bnAxWaBdvTdvM1hP62iZp0BXWDy4vTAy4fF0+Dlpg==}
dev: true
/fflate@0.8.0:
resolution: {integrity: sha512-FAdS4qMuFjsJj6XHbBaZeXOgaypXp8iw/Tpyuq/w3XA41jjLHT8NPA+n7czH/DDhdncq0nAyDZmPeWXh2qmdIg==}
dev: false
@@ -1832,6 +1865,10 @@ packages:
immediate: 3.0.6
dev: false
/lil-gui@0.17.0:
resolution: {integrity: sha512-MVBHmgY+uEbmJNApAaPbtvNh1RCAeMnKym82SBjtp5rODTYKWtM+MXHCifLe2H2Ti1HuBGBtK/5SyG4ShQ3pUQ==}
dev: true
/lilconfig@2.1.0:
resolution: {integrity: sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==}
engines: {node: '>=10'}
@@ -1903,6 +1940,10 @@ packages:
engines: {node: '>= 8'}
dev: true
/meshoptimizer@0.18.1:
resolution: {integrity: sha512-ZhoIoL7TNV4s5B6+rx5mC//fw8/POGyNxS/DZyCJeiZ12ScLfVwRE/GfsxwiTkMYYD5DmK2/JXnEVXqL4rF+Sw==}
dev: true
/methods@1.1.2:
resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==}
engines: {node: '>= 0.6'}
@@ -2799,6 +2840,10 @@ packages:
any-promise: 1.3.0
dev: true
/three@0.154.0:
resolution: {integrity: sha512-Uzz8C/5GesJzv8i+Y2prEMYUwodwZySPcNhuJUdsVMH2Yn4Nm8qlbQe6qRN5fOhg55XB0WiLfTPBxVHxpE60ug==}
dev: false
/to-regex-range@5.0.1:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}

View File

@@ -141,6 +141,7 @@
<option value="anthropic/claude-instant-v1-100k" class="bg-darkbg appearance-none">Claude Instant v1 100k</option>
<option value="anthropic/claude-v1" class="bg-darkbg appearance-none">Claude v1</option>
<option value="anthropic/claude-v1-100k" class="bg-darkbg appearance-none">Claude v1 100k</option>
<option value="anthropic/claude-1.2" class="bg-darkbg appearance-none">Claude v1.2</option>
</select>
{/if}
{#if $DataBase.aiModel.startsWith('gpt') || $DataBase.subModel.startsWith('gpt')}

View File

@@ -0,0 +1,62 @@
<script>
import { onDestroy, onMount } from 'svelte';
export let width = 800;
export let height = 600;
let canvas;
let animationFrameId;
onMount(async () => {
const { Scene, PerspectiveCamera, WebGLRenderer, AmbientLight, DirectionalLight } = await import('three');
const { MMDLoader } = await import('three/examples/jsm/loaders/MMDLoader')
const { MMDAnimationHelper } = await import('three/examples/jsm/animation/MMDAnimationHelper');
const scene = new Scene();
const camera = new PerspectiveCamera(75, width / height, 0.1, 1000);
const renderer = new WebGLRenderer({ canvas, alpha: true });
scene.add(new AmbientLight(0x666666));
scene.add(new DirectionalLight(0x887766));
camera.position.set(0, 10, 20);
camera.lookAt(scene.position);
const loader = new MMDLoader();
const helper = new MMDAnimationHelper();
loader.load( 'path/to/model.pmd', model => {
//@ts-ignore
const mesh = helper.createMesh(model);
scene.add(mesh);
//@ts-ignore
const vpdLoader = new VPDLoader();
vpdLoader.load( 'path/to/pose.vpd', vpd => {
helper.pose(mesh, vpd);
});
//@ts-ignore
helper.animate(mesh);
});
renderer.setSize(width, height);
function animate() {
animationFrameId = requestAnimationFrame(animate);
renderer.render(scene, camera);
}
animate();
});
onDestroy(() => {
cancelAnimationFrame(animationFrameId);
});
</script>
<div>
<canvas bind:this={canvas} style="width: {width}px; height: {height}px;"></canvas>
</div>

View File

@@ -95,7 +95,8 @@
{/if}
</Arcodion>
<Arcodion name="Anthropic Claude">
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('claude-2')}}>claude-v2</button>
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('claude-2')}}>claude-2</button>
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('claude-2-100k')}}>claude-2-100k</button>
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('claude-v1')}}>claude-v1</button>
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('claude-v1-100k')}}>claude-v1-100k</button>
<button class="p-2 hover:text-green-500" on:click={() => {changeModel('claude-instant-v1')}}>claude-instant-v1</button>

13
src/ts/3d/threeload.ts Normal file
View File

@@ -0,0 +1,13 @@
const { Scene, PerspectiveCamera, WebGLRenderer, AmbientLight, DirectionalLight } = await import('three');
const { MMDLoader } = await import('three/examples/jsm/loaders/MMDLoader')
const { MMDAnimationHelper } = await import('three/examples/jsm/animation/MMDAnimationHelper');
export {
Scene,
PerspectiveCamera,
WebGLRenderer,
AmbientLight,
DirectionalLight,
MMDLoader,
MMDAnimationHelper,
};

View File

@@ -310,6 +310,7 @@ export async function supaMemory(
currentTokens -= await tokenize(oldSupaMemory)
currentTokens += await tokenize(supaMemory)
}
console.log(supaMemory)
}
}