我只是在学习使用three.js.这似乎很好,但现在我有一个问题,我无法解决.
我想加载一个OBJ文件,我以前在blender中创建.为此,我尝试使用THREE.OBJloader.我从http://mamboleoo.be/learnThree/复制了代码,但是我在第32行得到了错误消息"THREE.OBJLoader不是构造函数".
其他一切正常:添加场景,添加材料,添加立方体等.
为了方便起见,这是代码:
var renderer, scene, camera, banana;
var ww = window.innerWidth,
wh = window.innerHeight;
function init(){
renderer = new THREE.WebGLRenderer({canvas : document.getElementById('scene')});
renderer.setSize(ww,wh);
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(50,ww/wh, 0.1, 10000 );
camera.position.set(0,0,500);
scene.add(camera);
//Add a light in the scene
directionalLight = new THREE.DirectionalLight( 0xffffff, 0.8 );
directionalLight.position.set( 0, 0, 350 );
directionalLight.lookAt(new THREE.Vector3(0,0,0));
scene.add( directionalLight );
//Load the obj file
loadOBJ();
}
var loadOBJ = function(){
//Manager from ThreeJs to track a loader …
Run Code Online (Sandbox Code Playgroud) 是否有任何工具可以从 YAML 生成 JavaScript 类?
我有一个大摇大摆的 YAML,我想生成如下所示的 javascript 模型:
'use strict';
function Product(name,description){
this.name = name;
this.description = description;
this.toString = function(){
return this.name+" : "+this.description;
}
Run Code Online (Sandbox Code Playgroud)
}
使用大摇大摆的 YAML :
.
.
.
definitions:
product:
properties:
name:
type: string
description:
type: string
required:
- name
- description
.
.
.
Run Code Online (Sandbox Code Playgroud) 我有一个非常基本的 Ionic Android 应用程序,使用 firebase 身份验证。当用户输入错误的凭据并且我发现错误时,我只需更改反应性属性即可向用户显示错误:
async login() {
try {
await this.authService.login(this.email, this.password);
this.error = "";
} catch (error) {
this.error = error;
}
}
Run Code Online (Sandbox Code Playgroud)
单击登录按钮时会调用此函数,authService 中的函数登录如下所示:
login(email: string, password: string) {
return this.afAuth.signInWithEmailAndPassword(email, password);
}
Run Code Online (Sandbox Code Playgroud)
在我的登录 html 页面中,我尝试显示如下错误:
<p>
<ion-text color="danger"><i>{{error}}</i></ion-text>
</p>
Run Code Online (Sandbox Code Playgroud)
一切都是基本的,没有什么花哨的,如果我通过 运行应用程序,一切都可以在浏览器中完美运行ionic serve
,但运行应用程序后,它在 Android 设备上的运行情况就不一样了ionic cordova run android
。
如果凭据错误,错误会被很好地捕获,但不会显示在界面上,除非我单击输入然后显示错误。我相信 Angular 不会检测更改,并且通过使用此处ChangeDetectorRef
解决方案中的描述,它可以工作。
但我发现这是解决这个错误的一种很奇怪的方法。为什么角度无法检测到变化本身?为什么它可以在浏览器上运行但不能在移动设备上运行?
我检查过许多其他类似的问题,但没有人发现它可以在浏览器上运行但不能在 Android 设备上运行。
android firebase ionic-framework firebase-authentication angular
这里有这家商店:
interface Task {
id?: string;
name: string;
done: boolean;
}
interface TodoState {
tasks: Task[];
loading: boolean;
}
export const useTodoStore = defineStore({
id: 'todo',
state: (): TodoState => ({
tasks: [],
loading: false,
}),
getters: {},
actions: {
async addTask(name: string): Promise<void> {
this.loading = true;
this.tasks.push({ name, done: false, id: generateID() });
await sleep(200);
this.loading = false;
},
},
});
Run Code Online (Sandbox Code Playgroud)
我不明白为什么当我将鼠标悬停在操作中的“任务”时,其类型不是 Task[] 但我得到
(property) tasks: {
id?: string | undefined;
name: string;
done: boolean;
}[]
Run Code Online (Sandbox Code Playgroud)
在玩 Vue 3 反应性时,我遇到了一种我无法解释的行为。
我创建了一个ref
原语。检查isRef
一下,显然返回了true
。但是当作为 a 传递给子组件时prop
,isRef()
也会isReactive()
返回false
。为什么 ?
另外,即使它们都返回false
,如果值发生变化,我在子组件中添加的这个道具的观察者也会被触发。如果监视的值不是ref
or ,它如何触发reactive
?
这是父级和子级的代码片段:
家长.vue
let foo = ref(0);
function changeFoo() {
foo.value++;
}
console.log("parent check is reactive?", isReactive(foo)); // retruns false
console.log("parent check is ref?", isRef(foo)); // retruns true
watch(foo, (value, oldValue) => {
console.log("foo changing from", oldValue, "to ", value);
});
Run Code Online (Sandbox Code Playgroud)
儿童.vue
const props = defineProps<{
foo: number;
}>();
console.log("child check …
Run Code Online (Sandbox Code Playgroud)