使用loadModel promise加载多个模型

时间:2019-09-23 08:08:41

标签: autodesk-forge autodesk-viewer

我想使用loadModel promise和loadAsHidden选项加载一系列模型。然后,一旦加载了所有模型,就立即显示所有模型。在运行loadModel命令之后,似乎每个诺言都得到了解决。因此,在模型完全加载之前运行showHiddenModels函数。 Storeys数组包含文件的svf地址。


.
.
.

<div class="mypopup"  id="myForm">
  <form method="get">
    <div style="text-align:right;padding-right:8px;color:#303A43;font-size:14px;">فیلترها </div>

    <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
            <div>
        <div>
        <label class="quti"  style="position:absolute;top:36px;right:16px;font-size:12px;color: #92A6B6;">از تاریخ</label>

    <div>
      <input type="number" name="CaseDate_Day__gte" step="any" id="id_CaseDate_Day__gte"
      style="top:58px;left:223px;position:absolute;width:47px;height:36px;border: 1px solid #CCDDEB;border-radius: 4px;opacity: 1;font-size:14px;
                letter-spacing: 0;color: #303A43;opacity: 1;text-align: center;float:right;direction:rtl;">
    </div>


    <script>
          var CaseDate_gte = document.getElementById("id_CaseDate_Year__gte").value
                            +document.getElementById("id_CaseDate_Month__gte").value
                            +document.getElementById("id_CaseDate_Day__gte").value;
    </script>


            <div style="width:60px;height:22px;color: #CCDDEB;font-size:19px;position:absolute;top:58px;left:210px;">/</div>


        <div>
          <input type="number" name="CaseDate_Month__gte" step="any" id="id_CaseDate_Month__gte" class="months">
        </div>


      <div style="width:6px;height:22px;color: #CCDDEB;font-size:19px;position:absolute;top:58px;left:93px;">/</div>

      <div>
        <input type="number" name="CaseDate_Year__gte" step="any" id="id_CaseDate_Year__gte" class="years">
      </div>


        </div>

    <div>
        <label class="quti" style="position:absolute;top:105px;right:16px;font-size:12px;color: #92A6B6;">تا تاریخ</label>


    <div>
      <input type="number" name="CaseDate_Day__lte" step="any" id="id_CaseDate_Day__lte" class="enddays">
    </div>

        <div style="width:6px;height:22px;color: #CCDDEB;font-size:19px;position:absolute;top:133px;left:210px;">/</div>

    <div>
      <input type="number" name="CaseDate_Month__lte" step="any" id="id_CaseDate_Month__lte" class="endmonths">
    </div>

        <div style="width:6px;height:22px;color: #CCDDEB;font-size:19px;position:absolute;top:133px;left:93px;">/</div>

    <div>
      <input type="number" name="CaseDate_Year__lte" step="any" id="id_CaseDate_Year__lte" class="endyears">
    </div>

        </div>
    </div>
    <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

    <div>
        <label for="incidentTypes" class="quti" style="position:absolute;top:181px;right:16px;font-size:12px;color: #92A6B6;">نوع پرونده</label>


    <select name="CaseType" id="id_CaseType" style="top:202px;right:16px;font-family:IRANSans;" class="vorudi">

      {% for obj in filter.form.fields.CaseType.choices %}
          <option value="{{ obj.0 }}"> {{ obj.1 }} </option>
      {% endfor %}

    </select>

        </div>




<div>
        <label for="cities" class="quti" style="top:258px;right:16px;font-size:12px;color: #92A6B6;position:absolute;">واحد پرونده</label>
    <select name="CaseType" id="id_CaseType" style="top:279px;right:16px;font-family:IRANSans;" class="vorudi">

      {% for obj in filter.form.fields.CaseUnit.choices %}
          <option value="{{ obj.0 }}"> {{ obj.1 }} </option>
      {% endfor %}

    </select>
    </div>



    <div>
        <label for="fraudTypes" class="quti" style="top:335px;right:16px;font-size:12px;color: #92A6B6;position:absolute;">واحد صدور</label>
    <select name="CaseType" id="id_CaseType" style="top:356px;right:16px;font-family:IRANSans;" class="vorudi">

      {% for obj in filter.form.fields.IssueUnit.choices %}
          <option value="{{ obj.0 }}"> {{ obj.1 }} </option>
      {% endfor %}

    </select>

    </div>

    <div style="position:absolute;top:410px;width:293px;right:16px;">
         <p style="text-align: right;font-size:12px;letter-spacing: 0;color: #92A6B6;;margin-bottom:0;">مشکوک بودن</p>

    <input type="range" name="weight" style="width:88%;" id="range_weight" value="5" min="1" max="100" oninput="range_weight_disp.value=range_weight.value">
    <output id="range_weight_disp"></output>


        </div>


    <button type="submit" style="position:absolute;top:458px;margin-top:24px;width: 325px;height: 48px;background: #00559A 0% 0% no-repeat padding-box;
        border-radius: 0px 0px 8px 8px;border:none;font-size:18px;color:white;font-family:IRANSans;" onclick="closeForm()">اعمال فیلتر</button>

  </form>
</div>

.
.
.



<div id="tableContainer" class="tableContainer">
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="scrollTable" style="font-family:IRANSans;">
<thead class="fixedHeader">
<tr>
<th width="90px" style="border-radius: 8px 0px 0px 0px;"> مشکوک بودن</th>
<th width="90px">نوع پرونده</th>
<th width="90px">واحد پرونده</th>
<th width="90px">واحد صدور</th>
<th width="90px">بیمه گزار</th>
<th width="90px">تاریخ پرونده</th>
<th width="90px" style="border-radius: 0px 8px 0px 0px;">کد پرونده</th>
</tr>
</thead>
<tbody class="scrollContent" style="font-family:IRANSans;">
{% for r in filter.qs %}
<tr style="font-family:IRANSans;">
<td width="200px" style="font-family:IRANSans;">{{r.FraudulantRate}}</td>
<td width="200px" style="font-family:IRANSans;">{{r.CaseType}}</td>
<td width="200px" style="font-family:IRANSans;">{{r.CaseUnit}}</td>
<td width="200px" style="font-family:IRANSans;">{{r.IssueUnit}}</td>
<td width="200px" style="font-family:IRANSans;">{{r.FinalInsurerName}}</td>
<td width="200px" style="font-family:IRANSans;">{{r.CaseDate}}</td>
<td width="200px"><a style="font-family:IRANSans;font-size:14px;" href="{% url 'caria_CaseDetail' r.id %}">{{r.CaseCode}}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>

.
.
.

这是它在控制台中的外观。因此,首先调用promise.then,然后开始加载文件。

Console

1 个答案:

答案 0 :(得分:1)

LoadModel会在加载模型种子文件后立即实现其诺言,而不是其完整的几何/纹理等。

对于完成模型加载的生命周期事件,请订阅Autodesk.Viewing.GEOMETRY_LOADED_EVENT

viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, event=>{
  //event {type:string, model:object, target:object}
})

在多个模型场景中,当每个模型都完成加载时,此事件将触发多次-使用model对象的ID来告知最后一个模型何时完全加载。