你好,这是我的代码的一部分 - 地球仪:)
function createGlobe(){
var normalMap = THREE.ImageUtils.loadTexture("images/earth_normal_2048.jpg");
var surfaceMap = THREE.ImageUtils.loadTexture("images/earth_surface_2048.jpg");
var specularMap = THREE.ImageUtils.loadTexture("images/earth_specular_2048.jpg");
var shader = THREE.ShaderLib["phong"];
var uniforms = THREE.UniformsUtils.clone(shader.uniforms);
uniforms["tNormal"] = {type:"t", value:normalMap};
uniforms["tDiffuse"] = {type:"t", value:surfaceMap};
uniforms["tSpecular"] = {type:"t", value:specularMap};
//uniforms["enableDiffuse"] = true;
//uniforms["enableSpecular"] = true;
var shaderMaterial = new THREE.ShaderMaterial({
fragmentShader:shader.fragmentShader,
vertexShader:shader.vertexShader,
uniforms:uniforms,
lights:false
});
var globeGeometry = new THREE.SphereGeometry(1,32,32);
//tangents are needed for the shader
globeGeometry.computeTangents();
globe = new THREE.Mesh(globeGeometry, shaderMaterial);
globe.rotation.z = 0.41;
earthgroup.add(globe);
}
Run Code Online (Sandbox Code Playgroud)
有问题的地方是 ShaderMaterial 参数“lights:true”,设置时出现以下错误
Uncaught TypeError: …Run Code Online (Sandbox Code Playgroud) 我在 Angular 中使用ngx-owl-carousel-o库。每个轮播项目都被创建为一个带有(点击)事件的 div。我遇到的问题是,在拖动轮播时,它总是会不合需要地触发点击事件,即点击应该只在不拖动时触发。
<owl-carousel-o [options]="customOptions" (dragging)="on_carouselDrag($event.dragging)">
<ng-container *ngFor="let item of items">
<ng-template carouselSlide>
<div (click)="on_itemSelected(item)">
<!-- ... -->
</div>
</ng-template>
</ng-container>
</owl-carousel-o>
Run Code Online (Sandbox Code Playgroud)
我已经制定了一个似乎有效的解决方案,但我不确定它是否适合使用setTimeout. 我基本上只是用它来延迟结束on_carouselDrag以确保on_vendorSelected首先触发。
on_itemSelected(item: string): void {
if(!this.isDragging){
// ...
}
}
on_carouselDrag(dragging: boolean){
setTimeout(() => {
this.isDragging = dragging;
}, 10 )
}
Run Code Online (Sandbox Code Playgroud)
如果可以改进这种方法,将不胜感激。
如何在组件中调用角度材质侧导航操作?我有一个用例,sidenav 仅在方法触发时才能打开/关闭callMethods()。我也不能简单地传递open(e)(callMethods()需要 1 个参数)。有办法实现这个目标吗?
应用程序.html
<mat-sidenav-container class="example-container">
<mat-sidenav #sidenav [mode]="mode.value">
<p>
some nav here
</p>
</mat-sidenav>
<mat-sidenav-content>
<p><button mat-button (click)="open(sidenav)">Toggle</button></p>
<p>
some text here
</p>
</mat-sidenav-content>
</mat-sidenav-container>
Run Code Online (Sandbox Code Playgroud)
应用程序.ts
open(e: any) {
e.toggle();
}
callMethods() {
this.open(); // required 1 arguments
this.otherMethod();
}
anotherMethod() {
this.open(); // required 1 arguments
this.otherMethod();
}
Run Code Online (Sandbox Code Playgroud)
注:我注意到有一个帖子,但不清楚
我使用CurrentCellDirtyStateChanged处理我的复选框单击事件.我想要做的是当我单击包含复选框的单元格时处理相同的事件,即当我单击单元格时,选中复选框并调用DirtyStateChanged.使用以下代码没有多大帮助,它甚至不会调用CurrentCellDirtyStateChanged.我已经没想完了.
private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
if(dataGridView.Columns[e.ColumnIndex].ReadOnly != true)
{
//option 1
(dataGridView.CurrentRow.Cells[e.ColumnIndex] as DataGridViewCheckBoxCell).Value = true;
//option 2
DataGridViewCheckBoxCell cbc = (dataGridView.CurrentRow.Cells[e.ColumnIndex] as DataGridViewCheckBoxCell);
cbc.Value = true;
//option 3
dataGridView.CurrentCell.Value = true;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试找出一种好方法来表明 ReplaySubject 当前为“空”。
import {ReplaySubject} from 'rxjs/ReplaySubject';
const rs = new ReplaySubject<Object>();
// ...
constructor(){
this.sub = rs.subscribe(...);
}
Run Code Online (Sandbox Code Playgroud)
每次调用构造函数时,它将重播主题中的所有项目。然而我的问题是 - 是否有一些我们可以监听的事件,告诉我们主题何时变空?
我唯一能想到的是在主题完成时触发自定义/不同的事件,如下所示:
rs.next({done:true});
Run Code Online (Sandbox Code Playgroud)
将数据传递给 next() 方法是表示 ReplaySubject (暂时)为空/没有事件的最佳方式吗?
javascript ×2
typescript ×2
angular ×1
angular9 ×1
c# ×1
checkbox ×1
checked ×1
click ×1
css ×1
datagridview ×1
drag ×1
mat-sidenav ×1
methods ×1
owl-carousel ×1
rxjs ×1
rxjs5 ×1
three.js ×1
winforms ×1